@nestjs/core
Version:
Nest - modern, fast, powerful node.js web framework (@core)
27 lines (26 loc) • 962 B
JavaScript
;
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
;
const hash = require("object-hash");
exports.HANDLER_METADATA_SYMBOL = Symbol.for('handler_metadata:cache');
class HandlerMetadataStorage {
constructor() {
this[_a] = new Map();
}
set(controller, methodName, metadata) {
const metadataKey = this.getMetadataKey(controller, methodName);
this[exports.HANDLER_METADATA_SYMBOL].set(metadataKey, metadata);
}
get(controller, methodName) {
const metadataKey = this.getMetadataKey(controller, methodName);
return this[exports.HANDLER_METADATA_SYMBOL].get(metadataKey);
}
getMetadataKey(controller, methodName) {
const ctor = controller.constructor;
const controllerKey = ctor && hash(ctor);
return controllerKey + methodName;
}
}
_a = exports.HANDLER_METADATA_SYMBOL;
exports.HandlerMetadataStorage = HandlerMetadataStorage;