Skip to content

Instantly share code, notes, and snippets.

@withinboredom
Created November 11, 2017 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save withinboredom/944d19cbfb8bddea1610e9b3173df387 to your computer and use it in GitHub Desktop.
Save withinboredom/944d19cbfb8bddea1610e9b3173df387 to your computer and use it in GitHub Desktop.
Bad Function
'use strict';
const handleEvent = function (options) {
if (!options) {
throw new Error('Options are missing.');
}
if (!options.eventHandler) {
throw new Error('Event handler is missing.');
}
if (!options.flow) {
throw new Error('Flow is missing.');
}
if (!options.domainEvent) {
throw new Error('Domain event is missing.');
}
if (!options.services) {
throw new Error('Services are missing.');
}
const { eventHandler, flow, domainEvent, services } = options;
return function (done) {
if (!done) {
throw new Error('Callback is missing.');
}
eventHandler.forStatelessFlow({ flow, domainEvent, services }, done);
};
};
module.exports = handleEvent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment