@methodus/server
Version:
dynamic rpc components
24 lines • 1.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
require("reflect-metadata");
const class_container_1 = require("../class-container");
let metadataKey = 'methodus';
/** the MethodConfig decorator registers the controller as a router
* @param {string} name - the identifier of the controller in the resolver.
* @param {Function[]} middlewares - an array of middlewares to apply to this controller}
*/
function MethodConfig(name, middlewares) {
return function (target) {
let existingMetadata = class_container_1.ClassContainer.get(name) || {};
existingMetadata.name = name;
let proto = target.prototype || target.__proto__;
if (target.methodus)
proto = target;
proto.methodus.name = name;
proto.methodus.middlewares = middlewares;
existingMetadata.middlewares = middlewares;
class_container_1.ClassContainer.set(name, existingMetadata);
};
}
exports.MethodConfig = MethodConfig;
//# sourceMappingURL=method-config.js.map