This commit is contained in:
2026-05-26 12:26:05 +02:00
parent db83c00ac7
commit 7de6864f70
24 changed files with 1156 additions and 1 deletions
+33
View File
@@ -0,0 +1,33 @@
import { config } from './config.js';
import { closePool } from './db/pool.js';
import { runMigrations } from './db/migrate.js';
import { buildServer } from './server.js';
async function main(): Promise<void> {
await runMigrations();
const app = await buildServer();
await app.listen({ host: config.host, port: config.port });
const scheme = config.tls.enabled ? 'https' : 'http';
app.log.info(`API docs: ${scheme}://localhost:${config.port}/api/docs`);
app.log.info(`Live feed: ${scheme === 'https' ? 'wss' : 'ws'}://localhost:${config.port}/api/ws/live`);
let closing = false;
const shutdown = async (signal: string): Promise<void> => {
if (closing) return;
closing = true;
app.log.info(`Received ${signal}, shutting down`);
await app.close();
await closePool();
process.exit(0);
};
process.on('SIGINT', () => void shutdown('SIGINT'));
process.on('SIGTERM', () => void shutdown('SIGTERM'));
}
main().catch((err) => {
console.error('Fatal startup error:', err);
process.exit(1);
});