UNPKG

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