import { ConfigService } from '@nestjs/config'; import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import { ValidationPipe } from '@nestjs/common'; async function bootstrap() { const app = await NestFactory.create(AppModule); app.enableCors({ origin: '*' }); app.useGlobalPipes( new ValidationPipe({ whitelist:true, // strips unknown properties from @Body() forbidNonWhitelisted:true, // throws 400 if unknown props are sent transform:true // converts query string numbers/booleans from strings → correct types }) ) const config = new DocumentBuilder() .setTitle('Chat app') .setDescription('The chat API description') .setVersion('1.0') // .addBearerAuth( // { // type: 'http', // scheme: 'bearer', // bearerFormat: 'JWT', // in: 'header', // }, // 'jwt', // ) .build(); const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('api', app, document); const configService=app.get(ConfigService) const port=configService.get('PORT')|| 3000; await app.listen(port); } bootstrap();