Skip to content

Commit

Permalink
chore: disable swagger on production
Browse files Browse the repository at this point in the history
  • Loading branch information
ByeongHunKim committed Sep 20, 2023
1 parent 4736bcd commit 94fbc59
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { env } from 'node:process'
import { NestFactory } from '@nestjs/core'
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'
import cookieParser from 'cookie-parser'
Expand All @@ -13,13 +14,15 @@ async function bootstrap() {

app.useLogger(app.get(CustomLogger))

// todo disable swagger on production
const config = new DocumentBuilder()
.setTitle('NestJS APIs')
.setDescription('This is a sample NestJS Boilerplate REST API')
.build()
const document = SwaggerModule.createDocument(app, config)
SwaggerModule.setup('api', app, document)
if (env.NODE_ENV !== 'production') {
const config = new DocumentBuilder()
.setTitle('NestJS APIs')
.setDescription('This is a sample NestJS Boilerplate REST API')
.setVersion('1.0')
.build()
const document = SwaggerModule.createDocument(app, config)
SwaggerModule.setup('api', app, document)
}

app.use(cookieParser())

Expand Down

0 comments on commit 94fbc59

Please sign in to comment.