import { NestFactory } from '@nestjs/core'; import { SwaggerModule, DocumentBuilder, SwaggerCustomOptions } from '@nestjs/swagger'; import { AppModule } from './app.module'; async function bootstrap() { const app = await NestFactory.create(AppModule); const apiVersion = 1; if (process.env.NODE_ENV === 'dev' || process.env.NODE_ENV === 'test') { const config = new DocumentBuilder() .setTitle('Gemwiki API') .setDescription('The Gemwiki API description') .setVersion('1.0') .addTag('gemwiki') .addServer(`https:/wiki.dahyeon.us/`) .addBearerAuth({ type: 'openIdConnect' }) .build(); const options: SwaggerCustomOptions = { ui: true, raw: ['yaml'], } const documentFactory = () => SwaggerModule.createDocument(app, config); SwaggerModule.setup(`v${apiVersion}/api`, app, documentFactory, options); } app.setGlobalPrefix(`v${apiVersion}`); app.enableCors() await app.listen(process.env.PORT ?? 3415); } bootstrap();