Skip to content

Commit

Permalink
refactor(): remove duplicate function getClassScope
Browse files Browse the repository at this point in the history
  • Loading branch information
zanminkian committed Dec 17, 2021
1 parent ffc0389 commit e909ef6
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions packages/core/middleware/container.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Scope, Type } from '@nestjs/common';
import { SCOPE_OPTIONS_METADATA } from '@nestjs/common/constants';
import { Type } from '@nestjs/common';
import { MiddlewareConfiguration } from '@nestjs/common/interfaces/middleware/middleware-configuration.interface';
import { NestContainer } from '../injector/container';
import { InstanceWrapper } from '../injector/instance-wrapper';
import { InstanceToken } from '../injector/module';
import { getClassScope } from "../helpers/get-class-scope";

export class MiddlewareContainer {
private readonly middleware = new Map<
Expand Down Expand Up @@ -44,7 +44,7 @@ export class MiddlewareContainer {
middleware.set(
token,
new InstanceWrapper({
scope: this.getClassScope(metatype),
scope: getClassScope(metatype),
name: token,
metatype,
token,
Expand All @@ -66,9 +66,4 @@ export class MiddlewareContainer {
}
return this.configurationSets.get(moduleName);
}

private getClassScope<T = unknown>(type: Type<T>): Scope {
const metadata = Reflect.getMetadata(SCOPE_OPTIONS_METADATA, type);
return metadata && metadata.scope;
}
}

0 comments on commit e909ef6

Please sign in to comment.