UNPKG

@gabliam/web-core

Version:
75 lines (74 loc) 2.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WebConfiguration = void 0; const interceptors_1 = require("./interceptors"); // eslint-disable-next-line import/no-cycle const server_starter_1 = require("./server-starter"); /** * Web Config * * This class is a storage of all web configuration */ class WebConfiguration { constructor(config) { var _a, _b; this._webconfig = []; this._webconfigAfterCtrl = []; this._globalInterceptors = []; this._globalPipes = []; this._serverConfigs = []; this._serverStarter = (_a = config === null || config === void 0 ? void 0 : config.serverStarter) !== null && _a !== void 0 ? _a : new server_starter_1.HttpServerStarter(); if ((_b = config === null || config === void 0 ? void 0 : config.includeErrorInterceptor) !== null && _b !== void 0 ? _b : true) { this._globalInterceptors.push(interceptors_1.SendErrorInterceptor); } if (config === null || config === void 0 ? void 0 : config.webconfig) { this._webconfig.push(...config.webconfig); } if (config === null || config === void 0 ? void 0 : config.webconfigAfterCtrl) { this._webconfigAfterCtrl.push(...config.webconfigAfterCtrl); } if (config === null || config === void 0 ? void 0 : config.globalInterceptors) { this._globalInterceptors.push(...config.globalInterceptors); } if (config === null || config === void 0 ? void 0 : config.globalPipes) { this._globalPipes.push(...config.globalPipes); } if (config === null || config === void 0 ? void 0 : config.serverConfigs) { this._serverConfigs.push(...config.serverConfigs); } } get webConfigs() { return this._webconfig.slice(); } get WebConfigAfterCtrls() { return this._webconfigAfterCtrl.slice(); } get globalInterceptors() { return this._globalInterceptors; } get globalPipes() { return this._globalPipes; } get serverConfigs() { return this._serverConfigs; } get serverStarter() { return this._serverStarter; } addwebConfig(webConfig) { this._webconfig.push(webConfig); } addWebConfigAfterCtrl(webConfig) { this._webconfigAfterCtrl.push(webConfig); } useGlobalInterceptor(...ids) { this._globalInterceptors.push(...ids); } useGlobalPipes(...ids) { this._globalPipes.push(...ids); } addServerConfigs(...configs) { this._serverConfigs.push(...configs); } } exports.WebConfiguration = WebConfiguration;