import { NestFactory } from '@nestjs/core'; import { FastifyAdapter, NestFastifyApplication, } from '@nestjs/platform-fastify'; import { AppModule } from './app.module'; import { ValidationPipe, VersioningType} from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { Logger } from 'nestjs-pino'; async function bootstrap() { const app = await NestFactory.create( AppModule, new FastifyAdapter(), { bufferLogs: true }, ); const logger = app.get(Logger); app.useLogger(logger); app.enableCors(); app.useGlobalPipes( new ValidationPipe({ whitelist: true, }), ); app.enableVersioning({ type: VersioningType.URI, }); const configService = app.get(ConfigService); const port = configService.get('port'); await app.listen(port, '0.0.0.0', (error, address) => { if (error) { logger.error(error); process.exit(1); } else { logger.log(`Server listening on ${address}`); } }); } bootstrap();