From d0e570e9f31eafed9c5db3b1520b37eb112e647e Mon Sep 17 00:00:00 2001 From: hoangtv49 <92872128+hoangtv49@users.noreply.github.com> Date: Wed, 2 Aug 2023 14:51:13 +0700 Subject: [PATCH] chore: hide swagger ui on prod (#888) (#894) (#895) --- src/app.controller.ts | 15 --------------- src/app.module.ts | 5 +---- src/app.service.ts | 21 --------------------- src/main.ts | 7 ++++++- 4 files changed, 7 insertions(+), 41 deletions(-) delete mode 100644 src/app.controller.ts delete mode 100644 src/app.service.ts diff --git a/src/app.controller.ts b/src/app.controller.ts deleted file mode 100644 index 9a51df66..00000000 --- a/src/app.controller.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Controller, Get } from '@nestjs/common'; -import { ApiTags } from '@nestjs/swagger'; - -import { AppService } from './app.service'; - -@ApiTags('dashboard') -@Controller() -export class AppController { - constructor(private readonly appService: AppService) {} - - @Get() - getHello(): string { - return this.appService.getHello(); - } -} diff --git a/src/app.module.ts b/src/app.module.ts index e20913f6..ac567b9e 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -3,8 +3,6 @@ import { Module } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { SharedModule } from './shared/shared.module'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; import { ComponentsModule } from './components/components.module'; import { AccountModule } from './components/account/account.module'; import { ServiceUtil } from './shared/utils/service.util'; @@ -28,7 +26,6 @@ import { AuthModule } from './auth/auth.module'; SoulboundTokenModule, NameTagModule, ], - controllers: [AppController], - providers: [AppService, ServiceUtil, MetricService], + providers: [ServiceUtil, MetricService], }) export class AppModule {} diff --git a/src/app.service.ts b/src/app.service.ts deleted file mode 100644 index a1e5d9de..00000000 --- a/src/app.service.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Injectable } from '@nestjs/common'; - -import { AkcLogger, RequestContext } from './shared'; -import * as appConfig from './shared/configs/configuration'; - -@Injectable() -export class AppService { - cosmosScanAPI: string; - private appParams; - - constructor(private readonly logger: AkcLogger) { - this.logger.setContext(AppService.name); - this.appParams = appConfig.default(); - this.cosmosScanAPI = this.appParams.cosmosScanAPI; - } - getHello(): string { - const ctx = new RequestContext(); - this.logger.log(ctx, 'Hello World!'); - return 'Hello World!'; - } -} diff --git a/src/main.ts b/src/main.ts index d79025e3..3936cb43 100644 --- a/src/main.ts +++ b/src/main.ts @@ -33,7 +33,12 @@ async function bootstrap() { .addBearerAuth() .build(); const document = SwaggerModule.createDocument(app, options); - SwaggerModule.setup('doc', app, document); + + if (process.env.NODE_ENV === 'production') { + SwaggerModule.setup('doc', app, null); + } else { + SwaggerModule.setup('doc', app, document); + } //bull-board const redisOpts = configService.get('cacheManagement.redis');