@nestjs/microservices
Advanced tools
Comparing version 5.3.6 to 5.3.7
@@ -5,2 +5,3 @@ "use strict"; | ||
const load_package_util_1 = require("@nestjs/common/utils/load-package.util"); | ||
const shared_utils_1 = require("@nestjs/common/utils/shared.utils"); | ||
const rxjs_1 = require("rxjs"); | ||
@@ -27,3 +28,4 @@ const constants_1 = require("../constants"); | ||
getService(name) { | ||
const options = this.options; | ||
const options = shared_utils_1.isObject(this.options) | ||
? Object.assign({}, this.options, { loader: '' }) : {}; | ||
if (!this.grpcClient[name]) { | ||
@@ -30,0 +32,0 @@ throw new invalid_grpc_service_exception_1.InvalidGrpcServiceException(); |
@@ -24,2 +24,3 @@ import { Controller } from '@nestjs/common/interfaces'; | ||
getDataMetatype(instance: any, callback: any): any; | ||
createGuardsFn(guards: any[], instance: Controller, callback: (...args) => any): Function | null; | ||
} |
@@ -23,2 +23,3 @@ "use strict"; | ||
const interceptors = this.interceptorsContextCreator.create(instance, callback, module); | ||
const fnCanActivate = this.createGuardsFn(guards, instance, callback); | ||
const handler = (args) => async () => { | ||
@@ -30,6 +31,3 @@ const [data, ...params] = args; | ||
return this.rpcProxy.create(async (...args) => { | ||
const canActivate = await this.guardsConsumer.tryActivate(guards, args, instance, callback); | ||
if (!canActivate) { | ||
throw new __1.RpcException(constants_2.FORBIDDEN_MESSAGE); | ||
} | ||
fnCanActivate && (await fnCanActivate(args)); | ||
return await this.interceptorsConsumer.intercept(interceptors, args, instance, callback, handler(args)); | ||
@@ -45,3 +43,12 @@ }, exceptionHandler); | ||
} | ||
createGuardsFn(guards, instance, callback) { | ||
const canActivateFn = async (args) => { | ||
const canActivate = await this.guardsConsumer.tryActivate(guards, args, instance, callback); | ||
if (!canActivate) { | ||
throw new __1.RpcException(constants_2.FORBIDDEN_MESSAGE); | ||
} | ||
}; | ||
return guards.length ? canActivateFn : null; | ||
} | ||
} | ||
exports.RpcContextCreator = RpcContextCreator; |
@@ -7,3 +7,2 @@ "use strict"; | ||
return async (...args) => { | ||
const host = new execution_context_host_1.ExecutionContextHost(args); | ||
try { | ||
@@ -13,2 +12,3 @@ return await targetCallback(...args); | ||
catch (e) { | ||
const host = new execution_context_host_1.ExecutionContextHost(args); | ||
return exceptionsHandler.handle(e, host); | ||
@@ -15,0 +15,0 @@ } |
{ | ||
"name": "@nestjs/microservices", | ||
"version": "5.3.6", | ||
"version": "5.3.7", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@microservices)", | ||
@@ -5,0 +5,0 @@ "author": "Kamil Mysliwiec", |
@@ -61,4 +61,5 @@ <p align="center"> | ||
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" /></a> <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> --> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a> | ||
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" /></a> <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> --> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a> <a href="https://genuinebee.com/"><img src="https://nestjs.com/img/genuinebee.svg" height="34" /></a> | ||
## Backers | ||
@@ -65,0 +66,0 @@ |
138685
3147
77