import { NestFactory } from '@nestjs/core'; <% if(swagger) { %> import { HttpStatus } from '@nestjs/common'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; <% } %> import { AppModule } from './app.module'; async function bootstrap() { const app = await NestFactory.create(AppModule); <% if (swagger) { %> const swaggerOptions = new DocumentBuilder() .setTitle('App Title') .setDescription('API Documentation for App') .setVersion('1.0.0') .build(); const swaggerDoc = SwaggerModule.createDocument(app, swaggerOptions); SwaggerModule.setup('/docs', app, swaggerDoc, { explorer: true, swaggerOptions: { docExpansion: 'list', filter: true, showRequestDuration: true, }, }); // These two lines prevent NOT_FOUND error for robots.txt and favicon.ico with Swagger app.use('/robots.txt', (req, res) => res.send('User-Agent: *\n' + 'Disallow: /')); app.use('/favicon.ico', (req, res) => res.sendStatus(HttpStatus.NO_CONTENT).end()); <% } %> await app.listen(3000); } bootstrap();