tailwind
Version:
tailwind is a base module for streaming and evented CQS applications.
23 lines (18 loc) • 525 B
JavaScript
const { Event } = require('commands-events'),
uuid = require('uuidv4');
const buildEvent = function (contextName, aggregateName, aggregateId, eventName, data) {
if (!data) {
data = eventName;
eventName = aggregateId;
aggregateId = uuid();
}
return new Event({
context: { name: contextName },
aggregate: { name: aggregateName, id: aggregateId },
name: eventName,
data,
metadata: { correlationId: uuid(), causationId: uuid() }
});
};
module.exports = buildEvent;
;