api: env config, fastify with /healthz and SPA static serving

Task: M0-T3
This commit is contained in:
iamdoubz committed 2026-10-17 14:20:52 -05:00
1 parent 0247137765
commit 08bd33eefa
6 files changed
+589 -4

No files matched your search

+17 -2
View File
@@ -1,4 +1,19 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { APP_NAME } from '@selfphoneng/shared';
import { buildApp } from './app.ts';
import { ConfigError, loadConfig } from './config.ts';
console.log(`${APP_NAME} api`);
let config;
try {
config = loadConfig();
} catch (err) {
if (!(err instanceof ConfigError)) throw err;
console.error(err.message);
process.exit(1);
}
const app = buildApp(config);
await app.listen({ host: '127.0.0.1', port: config.API_PORT });
for (const sig of ['SIGTERM', 'SIGINT'] as const) {
process.once(sig, () => void app.close().then(() => process.exit(0)));
}