promises.js 266 B

123456789101112
  1. /**
  2. * Transform an async function into an Express middleware
  3. *
  4. * Any error will be passed to the error middlewares via `next()`
  5. */
  6. function expressify(fn) {
  7. return (req, res, next) => {
  8. fn(req, res, next).catch(next)
  9. }
  10. }
  11. module.exports = { expressify }