Skip to content

Commit 66c0b8c

Browse files
sample(grpc) update packages to latest patch versions
1 parent e3356cf commit 66c0b8c

17 files changed

Lines changed: 57 additions & 29 deletions

bundle/common/Readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
5858

5959
#### Sponsors
6060

61-
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" /></a> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> &nbsp; <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> &nbsp; <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp;--> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a>
61+
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" /></a> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> &nbsp; <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> &nbsp; <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp;--> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a> &nbsp; <a href="https://genuinebee.com/"><img src="https://nestjs.com/img/genuinebee.svg" height="34" /></a>
62+
6263

6364
## Backers
6465

bundle/core/Readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
5858

5959
#### Sponsors
6060

61-
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" /></a> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> &nbsp; <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> &nbsp; <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp;--> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a>
61+
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" /></a> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> &nbsp; <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> &nbsp; <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp;--> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a> &nbsp; <a href="https://genuinebee.com/"><img src="https://nestjs.com/img/genuinebee.svg" height="34" /></a>
62+
6263

6364
## Backers
6465

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { RuntimeException } from './runtime.exception';
22
export declare class CircularDependencyException extends RuntimeException {
3-
constructor(context: string);
3+
constructor(context?: string);
44
}

bundle/core/errors/exceptions/circular-dependency.exception.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
33
const runtime_exception_1 = require("./runtime.exception");
44
class CircularDependencyException extends runtime_exception_1.RuntimeException {
55
constructor(context) {
6-
super(`A circular dependency has been detected inside ${context}. Please, make sure that each side of a bidirectional relationships are decorated with "forwardRef()".`);
6+
const ctx = context ? ` inside ${context}` : ``;
7+
super(`A circular dependency has been detected${ctx}. Please, make sure that each side of a bidirectional relationships are decorated with "forwardRef()".`);
78
}
89
}
910
exports.CircularDependencyException = CircularDependencyException;

bundle/core/injector/container.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Object.defineProperty(exports, "__esModule", { value: true });
33
const constants_1 = require("@nestjs/common/constants");
44
require("reflect-metadata");
5+
const circular_dependency_exception_1 = require("../errors/exceptions/circular-dependency.exception");
56
const invalid_module_exception_1 = require("../errors/exceptions/invalid-module.exception");
67
const unknown_module_exception_1 = require("../errors/exceptions/unknown-module.exception");
78
const application_ref_host_1 = require("../helpers/application-ref-host");
@@ -81,6 +82,9 @@ class NestContainer {
8182
module.addRelatedModule(related);
8283
}
8384
addComponent(component, token) {
85+
if (!component) {
86+
throw new circular_dependency_exception_1.CircularDependencyException();
87+
}
8488
if (!this.modules.has(token)) {
8589
throw new unknown_module_exception_1.UnknownModuleException();
8690
}

bundle/core/router/router-execution-context.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export declare class RouterExecutionContext {
4141
type: any;
4242
data: any;
4343
}, transforms: Transform<any>[]): Promise<any>;
44-
createGuardsFn(guards: any[], instance: Controller, callback: (...args) => any): (args: any[]) => Promise<void>;
44+
createGuardsFn(guards: any[], instance: Controller, callback: (...args) => any): Function | null;
4545
createPipesFn(pipes: any[], paramsOptions: (ParamProperties & {
4646
metatype?: any;
4747
})[]): (args: any, req: any, res: any, next: any) => Promise<void>;

bundle/microservices/Readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
5858

5959
#### Sponsors
6060

61-
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" /></a> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> &nbsp; <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> &nbsp; <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp;--> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a>
61+
<a href="https://scal.io"><img src="https://nestjs.com/img/scalio-logo.svg" width="110" /></a> &nbsp; <a href="http://angularity.io"><img src="http://angularity.io/media/logo.svg" height="30" /></a> &nbsp; <a href="http://gojob.com"><img src="https://gojob.com/w/wp-content/uploads/2017/02/cropped-Logo-web-home.png" height="40" /> &nbsp; <!--<a href="https://keycdn.com"><img src="https://nestjs.com/img/keycdn.svg" height="30" /></a> &nbsp;--> <a href="https://hostpresto.com"><img src="https://nestjs.com/img/hostpresto.png" height="30" /></a> &nbsp; <a href="https://genuinebee.com/"><img src="https://nestjs.com/img/genuinebee.svg" height="34" /></a>
62+
6263

6364
## Backers
6465

bundle/microservices/client/client-grpc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Object.defineProperty(exports, "__esModule", { value: true });
33
const logger_service_1 = require("@nestjs/common/services/logger.service");
44
const load_package_util_1 = require("@nestjs/common/utils/load-package.util");
5+
const shared_utils_1 = require("@nestjs/common/utils/shared.utils");
56
const rxjs_1 = require("rxjs");
67
const constants_1 = require("../constants");
78
const invalid_grpc_package_exception_1 = require("../exceptions/errors/invalid-grpc-package.exception");
@@ -23,7 +24,8 @@ class ClientGrpcProxy extends client_proxy_1.ClientProxy {
2324
this.grpcClient = this.createClient();
2425
}
2526
getService(name) {
26-
const options = this.options;
27+
const options = shared_utils_1.isObject(this.options)
28+
? Object.assign({}, this.options, { loader: '' }) : {};
2729
if (!this.grpcClient[name]) {
2830
throw new invalid_grpc_service_exception_1.InvalidGrpcServiceException();
2931
}

bundle/microservices/context/rpc-context-creator.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ export declare class RpcContextCreator {
2121
create(instance: Controller, callback: (data) => Observable<any>, module: any): (...args) => Promise<Observable<any>>;
2222
reflectCallbackParamtypes(instance: Controller, callback: (...args) => any): any[];
2323
getDataMetatype(instance: any, callback: any): any;
24+
createGuardsFn(guards: any[], instance: Controller, callback: (...args) => any): Function | null;
2425
}

bundle/microservices/context/rpc-context-creator.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,14 @@ class RpcContextCreator {
2020
const guards = this.guardsContextCreator.create(instance, callback, module);
2121
const metatype = this.getDataMetatype(instance, callback);
2222
const interceptors = this.interceptorsContextCreator.create(instance, callback, module);
23+
const fnCanActivate = this.createGuardsFn(guards, instance, callback);
2324
const handler = (args) => async () => {
2425
const [data, ...params] = args;
2526
const result = await this.pipesConsumer.applyPipes(data, { metatype }, pipes);
2627
return callback.call(instance, result, ...params);
2728
};
2829
return this.rpcProxy.create(async (...args) => {
29-
const canActivate = await this.guardsConsumer.tryActivate(guards, args, instance, callback);
30-
if (!canActivate) {
31-
throw new __1.RpcException(constants_2.FORBIDDEN_MESSAGE);
32-
}
30+
fnCanActivate && (await fnCanActivate(args));
3331
return await this.interceptorsConsumer.intercept(interceptors, args, instance, callback, handler(args));
3432
}, exceptionHandler);
3533
}
@@ -40,5 +38,14 @@ class RpcContextCreator {
4038
const paramtypes = this.reflectCallbackParamtypes(instance, callback);
4139
return paramtypes && paramtypes.length ? paramtypes[0] : null;
4240
}
41+
createGuardsFn(guards, instance, callback) {
42+
const canActivateFn = async (args) => {
43+
const canActivate = await this.guardsConsumer.tryActivate(guards, args, instance, callback);
44+
if (!canActivate) {
45+
throw new __1.RpcException(constants_2.FORBIDDEN_MESSAGE);
46+
}
47+
};
48+
return guards.length ? canActivateFn : null;
49+
}
4350
}
4451
exports.RpcContextCreator = RpcContextCreator;

0 commit comments

Comments
 (0)