UNPKG

@mdf.js/service-registry

Version:

MMS - API - Service Registry

48 lines 1.84 kB
"use strict"; /** * Copyright 2024 Mytra Control S.L. All rights reserved. * * Use of this source code is governed by an MIT-style license that can be found in the LICENSE file * or at https://opensource.org/licenses/MIT. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.Router = void 0; const tslib_1 = require("tslib"); const express_1 = tslib_1.__importDefault(require("express")); const types_1 = require("../types"); const config_controller_1 = require("./config.controller"); const config_model_1 = require("./config.model"); const config_service_1 = require("./config.service"); const PREFIX_PATH = `/${types_1.CONFIG_SERVICE_NAME}`; /** Router class */ class Router { /** * Create a new instance of the Router class * @param manager - Registry used by this component * @param path - prefix path for all the routes */ constructor(manager, path = PREFIX_PATH) { this.manager = manager; this.manager = manager; this.model = new config_model_1.Model(this.manager); this.service = new config_service_1.Service(this.model); this.controller = new config_controller_1.Controller(this.service); this._router = this.buildRoutes(path); } /** * Perform the instantiation of the routes in an express router * @param path - prefix path for all the routers */ buildRoutes(path) { const router = express_1.default.Router(); router.route(`${path}/readme`).get(this.controller.readme.bind(this.controller)); router.route(`${path}/:id`).get(this.controller.query.bind(this.controller)); return router; } /** Express router for health REST API component*/ get router() { return this._router; } } exports.Router = Router; //# sourceMappingURL=config.router.js.map