@goparrot/pubsub-event-bus
Version:
NestJS EventBus extension for RabbitMQ PubSub
25 lines • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PubsubEventHandler = void 0;
const cqrs_1 = require("@nestjs/cqrs");
const constant_1 = require("./constant");
function PubsubEventHandler(...params) {
return (target) => {
if (!params.length) {
return Reflect.decorate([Reflect.metadata(constant_1.PUBSUB_EVENT_HANDLER_METADATA, { events: [] }), (0, cqrs_1.EventsHandler)()], target);
}
let options = {};
let events;
const optionsOrEvent = params[params.length - 1];
if (typeof optionsOrEvent === 'object') {
options = optionsOrEvent;
events = params.slice(0, -1);
}
else {
events = params;
}
return Reflect.decorate([Reflect.metadata(constant_1.PUBSUB_EVENT_HANDLER_METADATA, { ...options, events }), (0, cqrs_1.EventsHandler)(...events)], target);
};
}
exports.PubsubEventHandler = PubsubEventHandler;
//# sourceMappingURL=PubsubEventHandler.js.map