flame/middleware/asyncWrapper.js
2021-05-10 17:47:26 +02:00

17 lines
No EOL
350 B
JavaScript

// const asyncWrapper = foo => (req, res, next) => {
// return Promise
// .resolve(foo(req, res, next))
// .catch(next);
// }
// module.exports = asyncWrapper;
function asyncWrapper(foo) {
return function (req, res, next) {
return Promise
.resolve(foo(req, res, next))
.catch(next);
}
}
module.exports = asyncWrapper;