UNPKG

1.08 kBJavaScriptView Raw
1"use strict";
2var _a;
3Object.defineProperty(exports, "__esModule", { value: true });
4exports.HandlerMetadataStorage = exports.HANDLER_METADATA_SYMBOL = void 0;
5const constants_1 = require("../injector/constants");
6exports.HANDLER_METADATA_SYMBOL = Symbol.for('handler_metadata:cache');
7class HandlerMetadataStorage {
8 constructor() {
9 this[_a] = new Map();
10 }
11 set(controller, methodName, metadata) {
12 const metadataKey = this.getMetadataKey(controller, methodName);
13 this[exports.HANDLER_METADATA_SYMBOL].set(metadataKey, metadata);
14 }
15 get(controller, methodName) {
16 const metadataKey = this.getMetadataKey(controller, methodName);
17 return this[exports.HANDLER_METADATA_SYMBOL].get(metadataKey);
18 }
19 getMetadataKey(controller, methodName) {
20 const ctor = controller.constructor;
21 const controllerKey = ctor && (ctor[constants_1.CONTROLLER_ID_KEY] || ctor.name);
22 return controllerKey + methodName;
23 }
24}
25exports.HandlerMetadataStorage = HandlerMetadataStorage;
26_a = exports.HANDLER_METADATA_SYMBOL;