Phases 2-4: Auth, providers, stream management

This commit is contained in:
2026-02-23 15:32:24 +01:00
parent 8ea3279c3b
commit 538c24c58f
14 changed files with 1530 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
import { buildApp } from './app.js';
import { config } from './config.js';
import { startTokenRefreshScheduler, stopTokenRefreshScheduler } from './services/token-refresh.service.js';
async function main() {
const app = await buildApp();
@@ -7,6 +8,19 @@ async function main() {
try {
await app.listen({ port: config.port, host: config.host });
app.log.info(`Server listening on ${config.host}:${config.port}`);
// Start background token refresh
startTokenRefreshScheduler(app.prisma, app.log);
// Graceful shutdown
for (const signal of ['SIGINT', 'SIGTERM'] as const) {
process.on(signal, async () => {
app.log.info(`Received ${signal}, shutting down...`);
stopTokenRefreshScheduler();
await app.close();
process.exit(0);
});
}
} catch (err) {
app.log.error(err);
process.exit(1);