@5minds/processcube_engine
Version:
The ProcessCube Engine. Stores and executes BPMNs.
30 lines • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.initialize = initialize;
exports.registerHttpRoute = registerHttpRoute;
const processcube_engine_sdk_1 = require("@5minds/processcube_engine_sdk");
const Contracts_1 = require("../../Contracts");
let container;
function initialize(iocContainer) {
container = iocContainer;
}
function registerHttpRoute(httpRoute, method, routeHandler, options) {
if (container.isBound(Contracts_1.customHttpRouteTag)) {
const customHttpRoutes = container.getAll(Contracts_1.customHttpRouteTag);
const httpRouteAlreadyRegistered = customHttpRoutes.some((registeredHttpRoute) => registeredHttpRoute.httpRoute === httpRoute && registeredHttpRoute.method === method);
if (httpRouteAlreadyRegistered) {
throw new processcube_engine_sdk_1.BadRequestError(`A HTTP route with the path '${httpRoute}' and method '${method}' is already registered.`, 'extension');
}
}
if (!httpRoute.startsWith('/')) {
httpRoute = `/${httpRoute}`;
}
const customHttpRoute = {
httpRoute: httpRoute,
method: method,
routeHandler: routeHandler,
options: options,
};
container.bind(Contracts_1.customHttpRouteTag).toConstantValue(customHttpRoute);
}
//# sourceMappingURL=CustomHttpRoute.js.map