Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .env.demo
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@ CONSUMER_CONFIG_MAX_DELIVER=4
AGGREGATE_STREAM=aggregate
DID_STREAM=did-notify
PULL_CONSUMER=hub-pull-consumer

ENABLE_SWAGGER=true

STATUS_LIST_HOST=

# Full NATS connection URL
Expand Down
26 changes: 21 additions & 5 deletions apps/api-gateway/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
import { Controller, Logger } from '@nestjs/common';
import { ApiBearerAuth } from '@nestjs/swagger';
import { Controller, Get, Logger, Redirect } from '@nestjs/common';
import { ApiBearerAuth, ApiExcludeEndpoint } from '@nestjs/swagger';
import { AppService } from './app.service';
import { ConfigService } from '@credebl/config/config.service';

@Controller()
@ApiBearerAuth()
export class AppController {
constructor(private readonly appService: AppService) {}
export class AppController {
constructor(
private readonly appService: AppService,
private readonly configService: ConfigService
) {}

private readonly logger = new Logger('AppController');

@Get()
@Redirect('/api', 302)
@ApiExcludeEndpoint()
redirectToSwagger(): { url?: string; statusCode: number } {
if (this.configService.isSwaggerAvailable) {
return { url: '/api', statusCode: 302 };
}

private readonly logger = new Logger('AppController');
return { statusCode: 200 };
}
}
4 changes: 4 additions & 0 deletions libs/config/src/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ export class ConfigService {
private get environment(): string {
return this.configService.get<string>('NODE_ENV');
}

get isSwaggerAvailable(): boolean {
return 'true' === this.configService.get<string>('ENABLE_SWAGGER');
}
}