@nestjs/microservices
Advanced tools
Comparing version 4.3.4 to 4.3.6
@@ -6,10 +6,10 @@ import { InstanceWrapper } from '@nestjs/core/injector/container'; | ||
export declare class MicroservicesModule { | ||
private static readonly clientsContainer; | ||
private static listenersController; | ||
static setup(container: any, config: any): void; | ||
static setupListeners(container: any, server: Server & CustomTransportStrategy): void; | ||
static setupClients(container: any): void; | ||
static bindListeners(controllers: Map<string, InstanceWrapper<Controller>>, server: Server & CustomTransportStrategy, module: string): void; | ||
static bindClients(controllers: Map<string, InstanceWrapper<Controller>>): void; | ||
static close(): void; | ||
private readonly clientsContainer; | ||
private listenersController; | ||
setup(container: any, config: any): void; | ||
setupListeners(container: any, server: Server & CustomTransportStrategy): void; | ||
setupClients(container: any): void; | ||
bindListeners(controllers: Map<string, InstanceWrapper<Controller>>, server: Server & CustomTransportStrategy, module: string): void; | ||
bindClients(controllers: Map<string, InstanceWrapper<Controller>>): void; | ||
close(): void; | ||
} |
@@ -16,7 +16,10 @@ "use strict"; | ||
class MicroservicesModule { | ||
static setup(container, config) { | ||
constructor() { | ||
this.clientsContainer = new container_1.ClientsContainer(); | ||
} | ||
setup(container, config) { | ||
const contextCreator = new rpc_context_creator_1.RpcContextCreator(new rpc_proxy_1.RpcProxy(), new exception_filters_context_1.ExceptionFiltersContext(config), new pipes_context_creator_1.PipesContextCreator(config), new pipes_consumer_1.PipesConsumer(), new guards_context_creator_1.GuardsContextCreator(container, config), new guards_consumer_1.GuardsConsumer(), new interceptors_context_creator_1.InterceptorsContextCreator(container, config), new interceptors_consumer_1.InterceptorsConsumer()); | ||
this.listenersController = new listeners_controller_1.ListenersController(MicroservicesModule.clientsContainer, contextCreator); | ||
this.listenersController = new listeners_controller_1.ListenersController(this.clientsContainer, contextCreator); | ||
} | ||
static setupListeners(container, server) { | ||
setupListeners(container, server) { | ||
if (!this.listenersController) { | ||
@@ -28,3 +31,3 @@ throw new runtime_exception_1.RuntimeException(); | ||
} | ||
static setupClients(container) { | ||
setupClients(container) { | ||
if (!this.listenersController) { | ||
@@ -39,3 +42,3 @@ throw new runtime_exception_1.RuntimeException(); | ||
} | ||
static bindListeners(controllers, server, module) { | ||
bindListeners(controllers, server, module) { | ||
controllers.forEach(({ instance }) => { | ||
@@ -45,3 +48,3 @@ this.listenersController.bindPatternHandlers(instance, server, module); | ||
} | ||
static bindClients(controllers) { | ||
bindClients(controllers) { | ||
controllers.forEach(({ instance, isNotMetatype }) => { | ||
@@ -51,3 +54,3 @@ !isNotMetatype && this.listenersController.bindClientsToProperties(instance); | ||
} | ||
static close() { | ||
close() { | ||
const clients = this.clientsContainer.getAllClients(); | ||
@@ -58,3 +61,2 @@ clients.forEach((client) => client.close()); | ||
} | ||
MicroservicesModule.clientsContainer = new container_1.ClientsContainer(); | ||
exports.MicroservicesModule = MicroservicesModule; |
@@ -7,2 +7,4 @@ import { NestContainer } from '@nestjs/core/injector/container'; | ||
private readonly logger; | ||
private readonly microservicesModule; | ||
private readonly socketModule; | ||
private readonly microserviceConfig; | ||
@@ -9,0 +11,0 @@ private readonly server; |
@@ -18,2 +18,6 @@ "use strict"; | ||
this.logger = new logger_service_1.Logger(NestMicroservice.name, true); | ||
this.microservicesModule = new microservices_module_1.MicroservicesModule(); | ||
this.socketModule = SocketModule | ||
? new SocketModule() | ||
: null; | ||
this.isTerminated = false; | ||
@@ -24,3 +28,3 @@ this.isInitialized = false; | ||
this.config = new application_config_1.ApplicationConfig(ioAdapter); | ||
microservices_module_1.MicroservicesModule.setup(container, this.config); | ||
this.microservicesModule.setup(container, this.config); | ||
this.microserviceConfig = Object.assign({ transport: transport_enum_1.Transport.TCP }, config); | ||
@@ -31,4 +35,4 @@ const { strategy } = config; | ||
setupModules() { | ||
SocketModule && SocketModule.setup(this.container, this.config); | ||
microservices_module_1.MicroservicesModule.setupClients(this.container); | ||
this.socketModule && this.socketModule.setup(this.container, this.config); | ||
this.microservicesModule.setupClients(this.container); | ||
this.setupListeners(); | ||
@@ -39,3 +43,3 @@ this.setIsInitialized(true); | ||
setupListeners() { | ||
microservices_module_1.MicroservicesModule.setupListeners(this.container, this.server); | ||
this.microservicesModule.setupListeners(this.container, this.server); | ||
} | ||
@@ -76,3 +80,3 @@ useWebSocketAdapter(adapter) { | ||
closeApplication() { | ||
SocketModule && SocketModule.close(); | ||
this.socketModule && this.socketModule.close(); | ||
this.callDestroyHook(); | ||
@@ -79,0 +83,0 @@ this.setIsTerminated(true); |
{ | ||
"name": "@nestjs/microservices", | ||
"version": "4.3.4", | ||
"version": "4.3.6", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@microservices)", | ||
@@ -5,0 +5,0 @@ "author": "Kamil Mysliwiec", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65829
1271