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
2 changes: 1 addition & 1 deletion libs/api-gateway/api-gateway.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class ApiGatewayModule {
return {
global: true,
module: ApiGatewayModule,
imports: [ThrottlerModule.forRoot(option.throttler), RestfulModule],
imports: [ThrottlerModule.forRoot(option.throttler), RestfulModule.forRoot(option.restful)],
controllers: [],
providers: [
{
Expand Down
21 changes: 14 additions & 7 deletions libs/api-gateway/restful/restful.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Module } from '@nestjs/common';
import { DynamicModule, Module } from '@nestjs/common';
import { ProxyController } from './controllers/proxy.controller';
import { HttpModule } from '@nestjs/axios';
import { ProxyService } from './services/proxy.service';
Expand All @@ -7,10 +7,17 @@ import { RequestService } from './services/request.service';
import { DocumentController } from './controllers/document.controller';
import { UpdateApiDocumentTask } from './tasks/update-api-document.task';
import { WsRequestService } from './services/ws-request.service';
import { RestfulOption } from './types/restful-option.type';

@Module({
imports: [HttpModule],
controllers: [DocumentController, ProxyController],
providers: [ProxyService, OpenApiService, RequestService, WsRequestService, UpdateApiDocumentTask]
})
export class RestfulModule {}
@Module({})
export class RestfulModule {
static forRoot(option: RestfulOption): DynamicModule {
console.log(option.isEnableDocument);
return {
module: RestfulModule,
imports: [HttpModule],
controllers: [...(option.isEnableDocument ? [DocumentController] : []), ProxyController],
providers: [ProxyService, OpenApiService, RequestService, WsRequestService, UpdateApiDocumentTask]
};
}
}
3 changes: 3 additions & 0 deletions libs/api-gateway/restful/types/restful-option.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type RestfulOption = {
isEnableDocument: boolean;
};
2 changes: 2 additions & 0 deletions libs/api-gateway/types/api-gateway-option.type.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { ThrottlerOption } from '../throttlers/types/throttler-option.type';
import { ApiServiceDetail } from '../restful/types/api-service.type';
import { RestfulOption } from '../restful/types/restful-option.type';

export type ApiGatewayOption = {
apiServices: ApiServiceDetail[];
excludeHeaders: string[];
openApiSecurityKeys: string[];
throttler: ThrottlerOption;
restful: RestfulOption;
libraryPath?: string;
};
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hodfords/nestjs-api-gateway",
"version": "10.0.11",
"version": "10.1.0",
"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.",
"author": "",
"private": false,
Expand Down
3 changes: 2 additions & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import { env } from '~config/env.config';
globalRateLimit: 60,
isEnable: true,
globalRateLimitTTL: 60
}
},
restful: { isEnableDocument: true }
})
],
controllers: [AppController],
Expand Down