@golemio/pid
Version:
Golemio PID Module
29 lines • 1.49 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.JISEventsController = void 0;
const JISEventsJsonSchema_1 = require("../../../schema-definitions/jis/datasources/JISEventsJsonSchema");
const controllers_1 = require("@golemio/core/dist/input-gateway/controllers");
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
class JISEventsController extends controllers_1.BaseController {
constructor() {
super("jis", new golemio_validator_1.JSONSchemaValidator("JISEventsDataValidation", JISEventsJsonSchema_1.jisEventsJsonSchema));
this.processData = async (inputData) => {
try {
await this.validator.Validate(inputData);
await this.sendMessageToExchange("input." + this.queuePrefix + ".refreshJISEvents", JSON.stringify({ data: inputData, shouldTriggerWebhooks: true }));
}
catch (err) {
if (err instanceof golemio_errors_1.AbstractGolemioError) {
throw err;
}
else {
throw new golemio_errors_1.GeneralError("Error while validating input data.", this.constructor.name, err, 422);
}
}
};
this.name = "JISEventsController";
}
}
exports.JISEventsController = JISEventsController;
//# sourceMappingURL=JISEventsController.js.map