Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean swagger configuration #94

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@ import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module';
import { JsonConsoleLogger } from './logging/json-logger';
import { INestApplication } from '@nestjs/common';

/**
* Configure swagger for app
*/
function setupSwagger(app: INestApplication) {
const config = new DocumentBuilder()
.setTitle('Safe Events Service')
.setDescription('Safe Events Service API')
.setVersion('1.0')
// .addTag('safe')
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('', app, document);
}

async function bootstrap() {
const app = await NestFactory.create(AppModule, {
Expand All @@ -14,17 +29,7 @@ async function bootstrap() {
: ['verbose', 'debug', 'log', 'error', 'warn'],
});

// Swagger Configuration
const config = new DocumentBuilder()
.setTitle('Safe Events Service')
.setDescription('Safe Events Service API')
.setVersion('1.0')
// .addTag('safe')
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('', app, document);
// End Swagger -------------

setupSwagger(app);
await app.listen(3000);
}
bootstrap();