diff --git a/lib/index.js b/lib/index.js index a67554f..46683eb 100644 --- a/lib/index.js +++ b/lib/index.js @@ -28,7 +28,9 @@ module.exports.controller = (basepath, middleware = []) => { if (target.__params) { target.__params.forEach(({ id, handler }) => { - router.param(id, handler); + router.param(id, (req, res, next, ...rest) => { + Promise.resolve(handler.call(target, req, res, next, ...rest)).catch(next); + }); }); }