()
| 311 | const PORT = appConfig.app.port; |
| 312 | |
| 313 | async function initializeServer() { |
| 314 | try { |
| 315 | const app = await createApp(); |
| 316 | const server = app.listen(PORT, () => { |
| 317 | logger.info(`Backend API service listening on port ${PORT}`); |
| 318 | }); |
| 319 | |
| 320 | // Initialize Socket.IO service |
| 321 | const socketService = SocketManager.getInstance(); |
| 322 | socketService.initialize(server); |
| 323 | |
| 324 | // Initialize RealtimeManager (pg_notify listener) |
| 325 | const realtimeManager = RealtimeManager.getInstance(); |
| 326 | await realtimeManager.initialize(); |
| 327 | |
| 328 | // Sync existing functions to Deno Deploy (non-blocking) |
| 329 | const functionService = FunctionService.getInstance(); |
| 330 | functionService.syncDeployment().catch((err) => { |
| 331 | logger.error('Failed to sync functions to Deno Deploy', { |
| 332 | error: err instanceof Error ? err.message : String(err), |
| 333 | }); |
| 334 | }); |
| 335 | |
| 336 | TelemetryService.getInstance().start(); |
| 337 | } catch (error) { |
| 338 | logger.error('Failed to initialize server', { |
| 339 | error: error instanceof Error ? error.message : String(error), |
| 340 | stack: error instanceof Error ? error.stack : undefined, |
| 341 | }); |
| 342 | process.exit(1); |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | void initializeServer(); |
| 347 |
no test coverage detected