Skip to content

Commit

Permalink
Merge pull request #8800 from ZanMinKian/refactor/remove_duplicate_fu…
Browse files Browse the repository at this point in the history
…nction

refactor(): remove duplicate function `getClassScope`
  • Loading branch information
kamilmysliwiec authored Feb 14, 2022
2 parents 848c655 + bc8b9e8 commit 50a847e
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 50a847e

Please sign in to comment.