@miracledevs/paradigm-express-webapi
Version:
An easy to use MVC WebApi implementation over Express.
47 lines • 1.75 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApiServer = void 0;
const api_router_1 = require("./api-router");
const express_1 = __importDefault(require("express"));
class ApiServer {
constructor() {
this._controllers = [];
}
get configurationBuilder() { return this._configurationBuilder; }
get expressApplication() { return this._expressApplication; }
get dependencyContainer() { return this._dependencyContainer; }
get routing() { return this._routing; }
get logger() { return this._logger; }
get controllers() { return this._controllers; }
setLogger(logger) {
this._logger = logger;
}
setConfigurationBuilder(configurationBuilder) {
this._configurationBuilder = configurationBuilder;
}
setDependencyContainer(injector) {
this._dependencyContainer = injector;
}
start() {
this._expressApplication = (0, express_1.default)();
this._routing = new api_router_1.ApiRouter(this._logger, this._dependencyContainer);
this.configureApplication();
this._routing.registerRoutes(this._expressApplication);
}
configureApplication() {
// override to configure express application.
}
registerController(controller) {
this._controllers.push(controller);
}
registerControllers(controllers) {
for (const controller of controllers) {
this.registerController(controller);
}
}
}
exports.ApiServer = ApiServer;
//# sourceMappingURL=api-server.js.map