import { NestFactory } from '@nestjs/core'; import { HttpAdapterHost } from '@nestjs/core'; import { ConfigService } from '@nestjs/config'; import { ValidationPipe } from '@nestjs/common'; import { FastifyAdapter, NestFastifyApplication, } from '@nestjs/platform-fastify'; import { AppModule } from './app.module.js'; import { MetricsService } from './metrics/metrics.service.js'; import { RequestIdInterceptor } from './common/http/request-id.interceptor.js'; async function bootstrap(): Promise { const app = await NestFactory.create( AppModule, new FastifyAdapter({ logger: true }), ); app.useGlobalInterceptors( new RequestIdInterceptor( app.get(HttpAdapterHost), app.get(MetricsService), ), ); app.useGlobalPipes( new ValidationPipe({ whitelist: true, forbidNonWhitelisted: true, transform: true, }), ); app.enableShutdownHooks(); const config = app.get(ConfigService); const port = config.getOrThrow('APP_PORT'); const host = config.getOrThrow('APP_HOST'); await app.listen(port, host); } await bootstrap();