@sourceloop/ctrl-plane-orchestrator-service
Version:
ARC SaaS Orchestrator service.
54 lines • 2.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventController = void 0;
const tslib_1 = require("tslib");
const rest_1 = require("@loopback/rest");
const core_1 = require("@loopback/core");
const types_1 = require("../services/types");
const logging_1 = require("@loopback/logging");
let EventController = class EventController {
constructor(orchestratorService) {
this.orchestratorService = orchestratorService;
}
async handleEvent(eventType, body) {
try {
await this.orchestratorService.handleEvent(eventType, body);
return { success: true };
}
catch (err) {
if (err instanceof Error) {
throw rest_1.HttpErrors.BadRequest(err.message);
}
// Log unexpected errors
this.logger.error(err);
throw new rest_1.HttpErrors.InternalServerError('An unexpected error occurred.');
}
}
};
exports.EventController = EventController;
tslib_1.__decorate([
(0, core_1.inject)(logging_1.LoggingBindings.WINSTON_LOGGER),
tslib_1.__metadata("design:type", logging_1.WinstonLogger)
], EventController.prototype, "logger", void 0);
tslib_1.__decorate([
(0, rest_1.post)('/events/{eventType}'),
tslib_1.__param(0, rest_1.param.path.string('eventType')),
tslib_1.__param(1, (0, rest_1.requestBody)({
content: {
'application/json': {
schema: {
type: 'object',
additionalProperties: true,
},
},
},
})),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [String, Object]),
tslib_1.__metadata("design:returntype", Promise)
], EventController.prototype, "handleEvent", null);
exports.EventController = EventController = tslib_1.__decorate([
tslib_1.__param(0, (0, core_1.inject)(types_1.OrchestratorServiceBindings.ORCHESTRATOR_SERVICE)),
tslib_1.__metadata("design:paramtypes", [Object])
], EventController);
//# sourceMappingURL=event.controller.js.map