1 | "use strict";
|
2 | var _a;
|
3 | Object.defineProperty(exports, "__esModule", { value: true });
|
4 | exports.HandlerMetadataStorage = exports.HANDLER_METADATA_SYMBOL = void 0;
|
5 | const constants_1 = require("../injector/constants");
|
6 | exports.HANDLER_METADATA_SYMBOL = Symbol.for('handler_metadata:cache');
|
7 | class 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 | }
|
25 | exports.HandlerMetadataStorage = HandlerMetadataStorage;
|
26 | _a = exports.HANDLER_METADATA_SYMBOL;
|