UNPKG

@methodus/server

Version:

Server components for @methodus workflow

49 lines 2.41 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Methods = void 0; require("reflect-metadata"); const framework_commons_1 = require("@methodus/framework-commons"); const serversList_1 = require("../servers/serversList"); const framework_injection_1 = __importDefault(require("@methodus/framework-injection")); var Methods; (function (Methods) { function MethodConfigBase(name, middlewares, repository) { return (target) => { const existingMetadata = framework_injection_1.default.ClassContainer.get(name) || {}; existingMetadata.name = name; const original = target.prototype.constructor; original.prototype.options = original.prototype.options || { servers: [], classes: [], clients: [], plugins: [] }; let proto = target.prototype || target.__proto__; if (target.methodus) { proto = target; } proto.methodus[name].isBase = true; proto.methodus_base = JSON.parse(JSON.stringify(proto.methodus[name])); serversList_1.Servers.classes[target.name] = { classType: target, controller: target, methodType: framework_commons_1.MethodType.Local, serverType: framework_commons_1.ServerType.Express, }; const methods = Object.getOwnPropertyNames(target.prototype); methods.forEach((methodName) => { return target.prototype[methodName]; }); if (target.prototype.constructor) { const staticMethods = Object.getOwnPropertyNames(target.prototype.constructor); staticMethods.forEach((methodName) => { return target.prototype.constructor[methodName]; }); } proto.methodus_base.middlewares = middlewares; target.methodus_base = proto.methodus_base; existingMetadata.middlewares = middlewares; framework_injection_1.default.ClassContainer.set(name, existingMetadata); }; } Methods.MethodConfigBase = MethodConfigBase; })(Methods = exports.Methods || (exports.Methods = {})); //# sourceMappingURL=method-config-base.js.map