This repository has been archived on 2026-08-23. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
pi-web/src/server/index.ts
T
snowspeeder c3e0011378
CI / Verify and package (ubuntu-latest) (push) Canceled after 0s
CI / Verify and package (windows-latest) (push) Canceled after 0s
feat: add Azure Speech voice mode
2026-08-04 07:28:48 -04:00

22 lines
954 B
JavaScript

#!/usr/bin/env node
import { readFileSync } from "node:fs";
import { effectivePiWebConfig, maxUploadBytes } from "../config.js";
import { buildApp } from "./app.js";
const { config } = effectivePiWebConfig();
const app = await buildApp({
bodyLimit: maxUploadBytes(process.env, config),
...tlsOptions(process.env),
});
await app.listen({ port: config.port ?? 8504, host: config.host ?? "127.0.0.1" });
function tlsOptions(env: NodeJS.ProcessEnv): { https?: { key: Buffer; cert: Buffer } } {
const keyPath = env["PI_WEB_TLS_KEY"];
const certPath = env["PI_WEB_TLS_CERT"];
if ((keyPath === undefined || keyPath === "") && (certPath === undefined || certPath === "")) return {};
if (keyPath === undefined || keyPath === "" || certPath === undefined || certPath === "") {
throw new Error("Set both PI_WEB_TLS_KEY and PI_WEB_TLS_CERT to enable HTTPS.");
}
return { https: { key: readFileSync(keyPath), cert: readFileSync(certPath) } };
}