import { fail } from "../http.js"; import { renderConfigPage } from "./page.js"; /** Must match `ROUTES.page` in `src/routes.ts`. */ const PAGE_PATH = '/dsh-brain'; /** Serve the configuration page. */ function servePage(deps, req, res) { if (req.method !== 'GET' && req.method !== 'HEAD') { fail(res, 405, 'method-not-allowed', true); return; } const html = renderConfigPage({ version: deps.version, settingsPath: deps.store.path }); res.writeHead(200, { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-store', 'content-length': Buffer.byteLength(html), }); if (req.method === 'HEAD') res.end(); else res.end(html); } /** The exact route the root aggregator registers for the settings page. */ export function createSettingsUiRoutes(deps) { return [ { kind: 'exact', path: PAGE_PATH, handler: (req, res) => servePage(deps, req, res), }, ]; }