mirror of
https://github.com/pawelmalak/flame.git
synced 2024-12-21 17:21:30 +03:00
17 lines
350 B
JavaScript
17 lines
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;
|