import { buildApp } from './app'; import { env } from '@/config'; import { logger } from '@/infrastructure/observability'; import { bootstrapDatabase, bootstrapRedis, bootstrapQueue, bootstrapStorage, setupGracefulShutdown, } from '@/bootstrap'; async function startServer(): Promise { try { logger.info('🚀 Bootstrapping SupportHub API Enterprise Modular Monolith...'); // Initialize Infrastructure Connections await bootstrapDatabase(); await bootstrapRedis(); await bootstrapQueue(); await bootstrapStorage(); // Create Fastify Instance — registers domain event handlers itself, see app.ts. const app = await buildApp(); // Register Graceful Shutdown Processors setupGracefulShutdown(app); // Listen on Configured Host and Port const address = await app.listen({ port: env.PORT, host: env.HOST, }); logger.info( { port: env.PORT, host: env.HOST, env: env.NODE_ENV }, `🟢 SupportHub API running at ${address}`, ); logger.info(`📚 Swagger OpenAPI documentation available at ${address}/docs`); } catch (error) { logger.error({ error }, '❌ Fatal error during server startup.'); process.exit(1); } } startServer();