api: env config, fastify with /healthz and SPA static serving
Task: M0-T3
This commit is contained in:
1 parent
0247137765
commit
08bd33eefa
6 files changed
+589
-4
No files matched your search
+17
-2
@@ -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)));
|
||||
}
|
||||
Reference in new issue
Block a user