@5minds/processcube_engine
Version:
The ProcessCube Engine. Stores and executes BPMNs.
69 lines • 4.56 kB
JavaScript
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApplicationRouter = void 0;
const express_1 = __importDefault(require("express"));
const inversify_1 = require("inversify");
const lodash_1 = __importDefault(require("lodash"));
const Api_1 = require("../../Api");
const Contracts_1 = require("../../Contracts");
const ApiRestSettings_1 = require("../../Contracts/ApiRestSettings");
let ApplicationRouter = class ApplicationRouter {
expressRouter;
applicationInfoController;
swaggerController;
constructor(applicationInfoController, swaggerController) {
this.applicationInfoController = applicationInfoController;
this.swaggerController = swaggerController;
}
async init() {
this.expressRouter = express_1.default.Router();
this.initRouting();
return Promise.resolve();
}
initRouting() {
this.createGetRoute(`/${ApiRestSettings_1.restSettings.baseRoute}/v1${ApiRestSettings_1.restSettings.paths.getApplicationInfo}`, lodash_1.default.bind(this.applicationInfoController.getApplicationInfo, this.applicationInfoController));
this.createGetRoute(`/${ApiRestSettings_1.restSettings.baseRoute}/v1${ApiRestSettings_1.restSettings.paths.getAuthorityAddress}`, lodash_1.default.bind(this.applicationInfoController.getAuthorityAddress, this.applicationInfoController));
this.createGetRoute(`/${ApiRestSettings_1.restSettings.baseRoute}/v1/swagger`, lodash_1.default.bind(this.swaggerController.getSwaggerJson, this.swaggerController));
this.createGetRoute(`/swagger`, lodash_1.default.bind(this.swaggerController.getSwaggerJson, this.swaggerController));
this.createGetRoute(`/`, lodash_1.default.bind(this.routeToInfoIfJsonContentElseSwagger, this));
this.createGetRoute(`/atlas_engine`, lodash_1.default.bind(this.applicationInfoController.getApplicationInfo, this.applicationInfoController));
this.createGetRoute(`/security/authority`, lodash_1.default.bind(this.applicationInfoController.getAuthorityAddressAsObject, this.applicationInfoController));
this.createGetRoute(`/atlas_engine/security/authority`, lodash_1.default.bind(this.applicationInfoController.getAuthorityAddressAsObject, this.applicationInfoController));
this.createGetRoute(`/atlas_engine/api/v1/metrics`, lodash_1.default.bind(this.applicationInfoController.getMetricsReport, this.applicationInfoController));
}
routeToInfoIfJsonContentElseSwagger(request, response) {
if (request.headers['content-type'] === 'application/json') {
return this.applicationInfoController.getApplicationInfo(request, response);
}
return this.swaggerController.getSwaggerHtml(request, response);
}
createGetRoute(route, controllerFunction) {
this.expressRouter.get(route, controllerFunction);
}
};
exports.ApplicationRouter = ApplicationRouter;
exports.ApplicationRouter = ApplicationRouter = __decorate([
(0, inversify_1.injectable)(),
__param(0, (0, inversify_1.inject)(Contracts_1.IocRegistrationKeys.api.httpEndpoints.ApplicationInfoController)),
__param(0, (0, inversify_1.optional)()),
__param(1, (0, inversify_1.inject)(Contracts_1.IocRegistrationKeys.api.httpEndpoints.SwaggerController)),
__param(1, (0, inversify_1.optional)()),
__metadata("design:paramtypes", [Api_1.ApplicationInfoController,
Api_1.SwaggerController])
], ApplicationRouter);
//# sourceMappingURL=ApplicationRouter.js.map