-
-
Save withinboredom/944d19cbfb8bddea1610e9b3173df387 to your computer and use it in GitHub Desktop.
Bad Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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