-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.dev.ts
33 lines (29 loc) · 952 Bytes
/
index.dev.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import "dotenv/config";
import { createServer, runServer } from "./src/server";
import ngrok from "@ngrok/ngrok";
import { createConfig, readString } from "./src/config";
import { createHandlers } from "./src/handler";
import { createClient } from "./src/client";
async function run() {
const ngrokListener = await ngrok.forward({
addr: 3000,
authtoken: readString("NGROK_AUTHTOKEN"),
});
const ngrokUrl = ngrokListener.url();
if (!ngrokUrl) {
throw new Error("Unable to retrieve ngrok URL");
}
console.log(`Exposing server on ${ngrokUrl}`);
const config = createConfig({
selfBaseUrl: ngrokUrl,
selfAuthorization: "secret",
});
const client = createClient(config);
const handlers = await createHandlers(config, client);
const server = createServer(config, handlers);
const serverInstance = await runServer(server, 3000, "127.0.0.1");
}
run().catch((err) => {
console.error(err);
process.exit(1);
});