Untitled
import { NestFactory } from '@nestjs/core'; import { ValidationPipe } from '@nestjs/common'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import { AppModule } from './app.module'; import { ConfigService } from '@nestjs/config'; async function bootstrap() { const app = await NestFactory.create(AppModule); const configService = app.get(ConfigService); app.useGlobalPipes(new ValidationPipe()); if (configService.get<string>('NODE_ENV') !== 'prod') { const config = new DocumentBuilder() .setTitle('API Documentation') .setDescription('The API description') .setVersion('1.0') // .addBearerAuth() .build(); const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('api', app, document); } await app.listen(configService.get<number>('NODE_PORT') ?? 3000); } bootstrap();
Leave a Comment