Skip to content

Commit

Permalink
Merge pull request #18 from MetinSeylan/hotfix/guard-fn-scope
Browse files Browse the repository at this point in the history
hotfix for guard injector scope
  • Loading branch information
MetinSeylan authored Nov 20, 2021
2 parents d22a890 + 98e32ed commit 03696f7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
7 changes: 5 additions & 2 deletions dist/Trace/Injectors/GuardInjector.js

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

2 changes: 1 addition & 1 deletion dist/Trace/Injectors/GuardInjector.js.map

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

2 changes: 1 addition & 1 deletion dist/tsconfig.build.tsbuildinfo

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metinseylan/nestjs-opentelemetry",
"version": "2.0.1",
"version": "2.0.2",
"description": "deeply integrated OpenTelemetry module for Nestjs",
"author": "[email protected]",
"license": "MIT",
Expand Down
7 changes: 5 additions & 2 deletions src/Trace/Injectors/GuardInjector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ export class GuardInjector extends BaseTraceInjector implements Injector {
const guards = this.getGuards(controller.metatype).map((guard) => {
const prototype = guard['prototype'] ?? guard;
const traceName = `Guard->${controller.name}.${prototype.constructor.name}`;
guard.canActivate = this.wrap(prototype.canActivate, traceName, {
prototype.canActivate = this.wrap(prototype.canActivate, traceName, {
controller: controller.name,
guard: prototype.constructor.name,
scope: 'CONTROLLER',
});
Object.assign(prototype, this);
this.loggerService.log(`Mapped ${traceName}`, this.constructor.name);
return guard;
});
Expand All @@ -44,12 +45,13 @@ export class GuardInjector extends BaseTraceInjector implements Injector {
(guard) => {
const prototype = guard['prototype'] ?? guard;
const traceName = `Guard->${controller.name}.${controller.metatype.prototype[key].name}.${prototype.constructor.name}`;
guard.canActivate = this.wrap(prototype.canActivate, traceName, {
prototype.canActivate = this.wrap(prototype.canActivate, traceName, {
controller: controller.name,
guard: prototype.constructor.name,
method: controller.metatype.prototype[key].name,
scope: 'CONTROLLER_METHOD',
});
Object.assign(prototype, this);
this.loggerService.log(
`Mapped ${traceName}`,
this.constructor.name,
Expand Down Expand Up @@ -90,6 +92,7 @@ export class GuardInjector extends BaseTraceInjector implements Injector {
scope: 'GLOBAL',
},
);
Object.assign(provider.metatype.prototype, this);
this.loggerService.log(`Mapped ${traceName}`, this.constructor.name);
}
}
Expand Down

0 comments on commit 03696f7

Please sign in to comment.