@nestjs/microservices
Advanced tools
Comparing version 4.5.1 to 4.5.2
@@ -10,4 +10,6 @@ "use strict"; | ||
switch (transport) { | ||
case transport_enum_1.Transport.REDIS: return new client_redis_1.ClientRedis(metadata); | ||
default: return new client_tcp_1.ClientTCP(metadata); | ||
case transport_enum_1.Transport.REDIS: | ||
return new client_redis_1.ClientRedis(metadata); | ||
default: | ||
return new client_tcp_1.ClientTCP(metadata); | ||
} | ||
@@ -14,0 +16,0 @@ } |
@@ -56,3 +56,3 @@ "use strict"; | ||
handleErrors(stream, callback) { | ||
stream.on(ERROR_EVENT, (err) => { | ||
stream.on(ERROR_EVENT, err => { | ||
if (err.code === 'ECONNREFUSED') { | ||
@@ -59,0 +59,0 @@ callback(err, null); |
@@ -31,3 +31,3 @@ "use strict"; | ||
this.socket = this.createSocket(); | ||
return new Promise((resolve) => { | ||
return new Promise(resolve => { | ||
this.bindEvents(this.socket, callback); | ||
@@ -43,5 +43,5 @@ this.socket.on(CONNECT_EVENT, () => { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const sendMessage = (socket) => { | ||
const sendMessage = socket => { | ||
socket.sendMessage(msg); | ||
socket.on(MESSAGE_EVENT, (buffer) => this.handleResponse(socket, callback, buffer)); | ||
socket.on(MESSAGE_EVENT, buffer => this.handleResponse(socket, callback, buffer)); | ||
}; | ||
@@ -74,3 +74,3 @@ if (this.isConnected) { | ||
bindEvents(socket, callback) { | ||
socket.on(ERROR_EVENT, (err) => { | ||
socket.on(ERROR_EVENT, err => { | ||
if (err.code === 'ECONNREFUSED') { | ||
@@ -77,0 +77,0 @@ callback(err, null); |
@@ -44,3 +44,4 @@ "use strict"; | ||
const filter = this.filters.find(({ exceptionMetatypes, func }) => { | ||
const hasMetatype = !!exceptionMetatypes.find(ExceptionMetatype => exception instanceof ExceptionMetatype); | ||
const hasMetatype = !exceptionMetatypes.length || | ||
!!exceptionMetatypes.find(ExceptionMetatype => exception instanceof ExceptionMetatype); | ||
return hasMetatype; | ||
@@ -47,0 +48,0 @@ }); |
@@ -11,3 +11,3 @@ "use strict"; | ||
const instancePrototype = Object.getPrototypeOf(instance); | ||
return this.metadataScanner.scanFromPrototype(instance, instancePrototype, (method) => this.exploreMethodMetadata(instance, instancePrototype, method)); | ||
return this.metadataScanner.scanFromPrototype(instance, instancePrototype, method => this.exploreMethodMetadata(instance, instancePrototype, method)); | ||
} | ||
@@ -14,0 +14,0 @@ exploreMethodMetadata(instance, instancePrototype, methodName) { |
@@ -21,3 +21,3 @@ "use strict"; | ||
bindClientsToProperties(instance) { | ||
for (const { property, metadata } of this.metadataExplorer.scanForClientHooks(instance)) { | ||
for (const { property, metadata, } of this.metadataExplorer.scanForClientHooks(instance)) { | ||
const client = client_proxy_factory_1.ClientProxyFactory.create(metadata); | ||
@@ -24,0 +24,0 @@ this.clientsContainer.addClient(client); |
@@ -47,3 +47,4 @@ "use strict"; | ||
controllers.forEach(({ instance, isNotMetatype }) => { | ||
!isNotMetatype && this.listenersController.bindClientsToProperties(instance); | ||
!isNotMetatype && | ||
this.listenersController.bindClientsToProperties(instance); | ||
}); | ||
@@ -53,3 +54,3 @@ } | ||
const clients = this.clientsContainer.getAllClients(); | ||
clients.forEach((client) => client.close()); | ||
clients.forEach(client => client.close()); | ||
this.clientsContainer.clear(); | ||
@@ -56,0 +57,0 @@ } |
@@ -19,5 +19,3 @@ "use strict"; | ||
this.microservicesModule = new microservices_module_1.MicroservicesModule(); | ||
this.socketModule = SocketModule | ||
? new SocketModule() | ||
: null; | ||
this.socketModule = SocketModule ? new SocketModule() : null; | ||
this.isTerminated = false; | ||
@@ -31,3 +29,5 @@ this.isInitialized = false; | ||
const { strategy } = config; | ||
this.server = strategy ? strategy : server_factory_1.ServerFactory.create(this.microserviceConfig); | ||
this.server = strategy | ||
? strategy | ||
: server_factory_1.ServerFactory.create(this.microserviceConfig); | ||
} | ||
@@ -60,3 +60,3 @@ setupModules() { | ||
listen(callback) { | ||
(!this.isInitialized) && this.setupModules(); | ||
!this.isInitialized && this.setupModules(); | ||
this.logger.log(constants_1.messages.MICROSERVICE_READY); | ||
@@ -85,3 +85,3 @@ this.server.listen(callback); | ||
const modules = this.container.getModules(); | ||
modules.forEach((module) => { | ||
modules.forEach(module => { | ||
this.callModuleInitHook(module); | ||
@@ -93,6 +93,7 @@ }); | ||
const components = [...module.routes, ...module.components]; | ||
iterare_1.default(components).map(([key, { instance }]) => instance) | ||
.filter((instance) => !shared_utils_1.isNil(instance)) | ||
iterare_1.default(components) | ||
.map(([key, { instance }]) => instance) | ||
.filter(instance => !shared_utils_1.isNil(instance)) | ||
.filter(this.hasOnModuleInitHook) | ||
.forEach((instance) => instance.onModuleInit()); | ||
.forEach(instance => instance.onModuleInit()); | ||
} | ||
@@ -104,3 +105,3 @@ hasOnModuleInitHook(instance) { | ||
const modules = this.container.getModules(); | ||
modules.forEach((module) => { | ||
modules.forEach(module => { | ||
this.callModuleDestroyHook(module); | ||
@@ -111,6 +112,7 @@ }); | ||
const components = [...module.routes, ...module.components]; | ||
iterare_1.default(components).map(([key, { instance }]) => instance) | ||
.filter((instance) => !shared_utils_1.isNil(instance)) | ||
iterare_1.default(components) | ||
.map(([key, { instance }]) => instance) | ||
.filter(instance => !shared_utils_1.isNil(instance)) | ||
.filter(this.hasOnModuleDestroyHook) | ||
.forEach((instance) => instance.onModuleDestroy()); | ||
.forEach(instance => instance.onModuleDestroy()); | ||
} | ||
@@ -117,0 +119,0 @@ hasOnModuleDestroyHook(instance) { |
{ | ||
"name": "@nestjs/microservices", | ||
"version": "4.5.1", | ||
"version": "4.5.2", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@microservices)", | ||
@@ -5,0 +5,0 @@ "author": "Kamil Mysliwiec", |
@@ -10,4 +10,6 @@ "use strict"; | ||
switch (transport) { | ||
case transport_enum_1.Transport.REDIS: return new server_redis_1.ServerRedis(config); | ||
default: return new server_tcp_1.ServerTCP(config); | ||
case transport_enum_1.Transport.REDIS: | ||
return new server_redis_1.ServerRedis(config); | ||
default: | ||
return new server_tcp_1.ServerTCP(config); | ||
} | ||
@@ -14,0 +16,0 @@ } |
@@ -48,3 +48,3 @@ "use strict"; | ||
const patterns = Object.keys(this.messageHandlers); | ||
patterns.forEach((pattern) => sub.subscribe(this.getAckQueueName(pattern))); | ||
patterns.forEach(pattern => sub.subscribe(this.getAckQueueName(pattern))); | ||
callback && callback(); | ||
@@ -71,3 +71,3 @@ } | ||
getPublisher(pub, pattern) { | ||
return (respond) => { | ||
return respond => { | ||
pub.publish(this.getResQueueName(pattern), JSON.stringify(respond)); | ||
@@ -91,5 +91,5 @@ }; | ||
handleErrors(stream) { | ||
stream.on(ERROR_EVENT, (err) => this.logger.error(err)); | ||
stream.on(ERROR_EVENT, err => this.logger.error(err)); | ||
} | ||
} | ||
exports.ServerRedis = ServerRedis; |
@@ -17,4 +17,4 @@ import { Logger } from '@nestjs/common/services/logger.service'; | ||
send(stream$: Observable<any>, respond: (data: MicroserviceResponse) => void): Subscription; | ||
transformToObservable(resultOrDeffered: any): Observable<any>; | ||
transformToObservable(resultOrDeffered: any): any; | ||
protected handleError(error: string): void; | ||
} |
@@ -5,2 +5,3 @@ "use strict"; | ||
const Observable_1 = require("rxjs/Observable"); | ||
const shared_utils_1 = require("@nestjs/common/utils/shared.utils"); | ||
require("rxjs/add/operator/catch"); | ||
@@ -23,3 +24,4 @@ require("rxjs/add/operator/finally"); | ||
send(stream$, respond) { | ||
return stream$.catch((err) => { | ||
return stream$ | ||
.catch(err => { | ||
respond({ err, response: null }); | ||
@@ -29,3 +31,3 @@ return Observable_1.Observable.empty(); | ||
.finally(() => respond({ disposed: true })) | ||
.subscribe((response) => respond({ err: null, response })); | ||
.subscribe(response => respond({ err: null, response })); | ||
} | ||
@@ -36,3 +38,3 @@ transformToObservable(resultOrDeffered) { | ||
} | ||
else if (!(resultOrDeffered instanceof Observable_1.Observable)) { | ||
else if (!(resultOrDeffered && shared_utils_1.isFunction(resultOrDeffered.subscribe))) { | ||
return Observable_1.Observable.of(resultOrDeffered); | ||
@@ -39,0 +41,0 @@ } |
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
64428
1298