Skip to content

Commit 1416141

Browse files
feat: disable document page
1 parent b9f3254 commit 1416141

File tree

7 files changed

+25
-12
lines changed

7 files changed

+25
-12
lines changed

libs/api-gateway/api-gateway.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class ApiGatewayModule {
1111
return {
1212
global: true,
1313
module: ApiGatewayModule,
14-
imports: [ThrottlerModule.forRoot(option.throttler), RestfulModule],
14+
imports: [ThrottlerModule.forRoot(option.throttler), RestfulModule.forRoot(option.restful)],
1515
controllers: [],
1616
providers: [
1717
{
Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Module } from '@nestjs/common';
1+
import { DynamicModule, Module } from '@nestjs/common';
22
import { ProxyController } from './controllers/proxy.controller';
33
import { HttpModule } from '@nestjs/axios';
44
import { ProxyService } from './services/proxy.service';
@@ -7,10 +7,17 @@ import { RequestService } from './services/request.service';
77
import { DocumentController } from './controllers/document.controller';
88
import { UpdateApiDocumentTask } from './tasks/update-api-document.task';
99
import { WsRequestService } from './services/ws-request.service';
10+
import { RestfulOption } from './types/restful-option.type';
1011

11-
@Module({
12-
imports: [HttpModule],
13-
controllers: [DocumentController, ProxyController],
14-
providers: [ProxyService, OpenApiService, RequestService, WsRequestService, UpdateApiDocumentTask]
15-
})
16-
export class RestfulModule {}
12+
@Module({})
13+
export class RestfulModule {
14+
static forRoot(option: RestfulOption): DynamicModule {
15+
console.log(option.isEnableDocument);
16+
return {
17+
module: RestfulModule,
18+
imports: [HttpModule],
19+
controllers: [...(option.isEnableDocument ? [DocumentController] : []), ProxyController],
20+
providers: [ProxyService, OpenApiService, RequestService, WsRequestService, UpdateApiDocumentTask]
21+
};
22+
}
23+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export type RestfulOption = {
2+
isEnableDocument: boolean;
3+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { ThrottlerOption } from '../throttlers/types/throttler-option.type';
22
import { ApiServiceDetail } from '../restful/types/api-service.type';
3+
import { RestfulOption } from '../restful/types/restful-option.type';
34

45
export type ApiGatewayOption = {
56
apiServices: ApiServiceDetail[];
67
excludeHeaders: string[];
78
openApiSecurityKeys: string[];
89
throttler: ThrottlerOption;
10+
restful: RestfulOption;
911
libraryPath?: string;
1012
};

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hodfords/nestjs-api-gateway",
3-
"version": "10.0.11",
3+
"version": "10.1.0",
44
"description": "The API Gateway houses the source code and documentation for the API Gateway - a powerful and versatile solution for managing and deploying APIs within a distributed and microservices-oriented architecture.",
55
"author": "",
66
"private": false,

src/app.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import { env } from '~config/env.config';
2020
globalRateLimit: 60,
2121
isEnable: true,
2222
globalRateLimitTTL: 60
23-
}
23+
},
24+
restful: { isEnableDocument: true }
2425
})
2526
],
2627
controllers: [AppController],

0 commit comments

Comments
 (0)