33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { NestFactory } from '@nestjs/core';
|
|
import { AppModule } from './app.module';
|
|
import { ValidationPipe } from '@nestjs/common';
|
|
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
|
import { SwaggerDocumentOptions } from '@nestjs/swagger';
|
|
|
|
async function bootstrap() {
|
|
const app = await NestFactory.create(AppModule, {cors:{
|
|
"origin": "*",
|
|
"methods": "GET,HEAD,PUT,PATCH,POST,DELETE",
|
|
"preflightContinue": false,
|
|
"optionsSuccessStatus": 204
|
|
}});
|
|
app.useGlobalPipes(new ValidationPipe());
|
|
|
|
const config = new DocumentBuilder()
|
|
.setTitle('API')
|
|
.setDescription('API description')
|
|
.setVersion('1.0')
|
|
.addServer("http://localhost:3000", "Development Server 1")
|
|
.addServer("https://dev.alphaomegainfosys.com/test-api", "Development Server 2")
|
|
.build();
|
|
|
|
const options: SwaggerDocumentOptions = {
|
|
autoTagControllers: false,
|
|
};
|
|
const documentFactory = () => SwaggerModule.createDocument(app, config, options);
|
|
SwaggerModule.setup('api', app, documentFactory);
|
|
|
|
await app.listen(process.env.PORT ?? 3000);
|
|
}
|
|
bootstrap();
|