main.ts 825 B

123456789101112131415161718192021222324
  1. import { NestFactory } from '@nestjs/core';
  2. import { AppModule } from './app.module';
  3. import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
  4. import { ValidationPipe } from '@nestjs/common';
  5. import { ErrorsInterceptor } from './interceptor/errors.interceptor';
  6. async function bootstrap() {
  7. const app = await NestFactory.create(AppModule);
  8. app.useGlobalPipes(new ValidationPipe());
  9. app.useGlobalInterceptors(new ErrorsInterceptor());
  10. app.setGlobalPrefix('api');
  11. // SWAGGER
  12. const config = new DocumentBuilder()
  13. .setTitle(process.env.npm_package_name)
  14. .setDescription('Base nest js')
  15. .setVersion(process.env.npm_package_version)
  16. .build();
  17. const document = SwaggerModule.createDocument(app, config);
  18. SwaggerModule.setup('api', app, document);
  19. await app.listen(3000);
  20. }
  21. bootstrap();