Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 3 additions & 1 deletion .env.demo
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,6 @@ CONSUMER_CONFIG_MAX_DELIVER=4

AGGREGATE_STREAM=aggregate
DID_STREAM=did-notify
PULL_CONSUMER=hub-pull-consumer
PULL_CONSUMER=hub-pull-consumer

ENABLE_SWAGGER=true
4 changes: 3 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,6 @@ CONSUMER_CONFIG_MAX_DELIVER=4

AGGREGATE_STREAM=aggregate
DID_STREAM=did-notify
PULL_CONSUMER=hub-pull-consumer
PULL_CONSUMER=hub-pull-consumer

ENABLE_SWAGGER=true
Comment thread
joaoMiraya marked this conversation as resolved.
Outdated
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', 301)
@ApiExcludeEndpoint()
redirectToSwagger(): { url?: string; statusCode: number } {
if (this.configService.isSwaggerAvailable) {
return { url: '/api', statusCode: 301 };
}

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 this.configService.get<boolean>('ENABLE_SWAGGER');
Comment thread
joaoMiraya marked this conversation as resolved.
Outdated
}
}