@methodus/server
Version:
dynamic rpc components
28 lines • 1.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
require("reflect-metadata");
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 ServerConfiguration(serverType, options) {
return function (target) {
var original = target;
original.prototype.options = original.prototype.options || { servers: [], classes: [] };
original.prototype.options.servers.push({ serverType: serverType, options: options });
// the new constructor behaviour
var f = function (configOptions) {
// if (!configOptions || Object.keys(configOptions).length === 0)
// configOptions = { servers: [], classes: [] };
let instance = new original(original.prototype.options);
return instance;
};
// copy prototype so intanceof operator still works
f.prototype = original.prototype;
// return new constructor (will override original)
return f;
};
}
exports.ServerConfiguration = ServerConfiguration;
//# sourceMappingURL=server.js.map