UNPKG

@methodus/server

Version:

Server components for @methodus workflow

57 lines 1.94 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConfiguredServer = void 0; const tslib_1 = require("tslib"); const commons_1 = require("@methodus/framework-decorators/commons"); const server_1 = require("./server"); const events_1 = require("events"); class ConfiguredServer extends events_1.EventEmitter { constructor(target) { super(); if (target) { this.target = target; } this.init(); } init() { return tslib_1.__awaiter(this, void 0, void 0, function* () { let options = {}; if (this.target) { options = this.target.prototype.options; } else { options = this.__proto__.options; } const server = new server_1.Server(); this.server = server; server.config = new commons_1.MethodusConfig(); options.servers.forEach((element) => { if (server.config) { server.config.run(element.serverType, element.options); } }); options.classes.forEach((element) => { if (server.config) { server.config.use(element.controller, element.methodType, element.serverType); } }); options.clients.forEach((element) => { if (server.config) { server.config.useClient(element.controller, element.transportType, element.resolver); } }); if (options.plugins) { server.plugins(options.plugins); } yield server.start(); this.emit('ready', server); }); } kill() { if (this.server) { this.server.kill(); } } } exports.ConfiguredServer = ConfiguredServer; //# sourceMappingURL=server.configured.js.map