@onehilltech/blueprint
Version:
lightweight, simple, elegant framework for building mean applications
20 lines (19 loc) • 449 B
JavaScript
/**
* Factory method for creating a middleware function for the execute
* function that returns a Promise.
*
* @param action Action to execute
* @returns {Function}
*/
module.exports = function (action) {
return function __blueprint_execute_action (req, res, next) {
try {
Promise.resolve (action.execute (req, res))
.then (() => next ())
.catch (next);
}
catch (ex) {
next (ex);
}
}
};