123456789101112131415161718192021222324252627282930 |
- import { NestFactory } from '@nestjs/core';
- import { AppModule } from './app.module';
- import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
- import { ValidationPipe } from '@nestjs/common';
- import { ErrorsInterceptor } from './interceptor/errors.interceptor';
- import mainConfig from 'config.json';
- async function bootstrap() {
- const app = await NestFactory.create(AppModule);
- app.useGlobalPipes(new ValidationPipe());
- app.useGlobalInterceptors(new ErrorsInterceptor());
- app.setGlobalPrefix('api');
- app.enableCors({
- origin: mainConfig.cors,
- credentials: true,
- exposedHeaders: ['set-cookie'],
- });
- // SWAGGER
- const config = new DocumentBuilder()
- .setTitle(process.env.npm_package_name)
- .setDescription('Base nest js')
- .setVersion(process.env.npm_package_version)
- .build();
- const document = SwaggerModule.createDocument(app, config);
- SwaggerModule.setup('api', app, document);
- await app.listen(mainConfig.port);
- }
- bootstrap();
|