/** * Starts the admin page. It talks to the content service with the admin * token and must be published on the tailnet only. */ import { ContentApi } from "./client.ts"; import { createAdminServer } from "./server.ts"; const contentUrl = process.env.CONTENT_URL ?? "http://localhost:4310"; const token = process.env.ADMIN_TOKEN; if (!token) throw new Error("ADMIN_TOKEN is required: the content service's admin token"); const port = Number(process.env.PORT ?? 4320); const host = process.env.HOST ?? "0.0.0.0"; const server = createAdminServer(new ContentApi(contentUrl, token)); server.listen(port, host, () => console.log(`Admin page on ${host}:${port}, using ${contentUrl}`)); const stop = () => server.close(() => process.exit(0)); process.on("SIGTERM", stop); process.on("SIGINT", stop);