bin/middleware.js
function(err, req, res, next) {

        function done(error) {
            log(req, util.format('middleware-end %s', name));
            next(error);
        }

        if (err && !errHandler) {
            log(req, util.format('skipped %s Hook is not for error handling', name));
            next(err);

        } else if (!err && errHandler) {
            log(req, util.format('skipped %s Hook is for error handling', name));
            next();

        } else {
            try {
                log(req, util.format('middleware-start %s', name));
                errHandler ? hook(err, req, res, done) : hook(req, res, done);
            } catch (err) {
                done(err);
            }

        }
    }
function(err, req, res, next) {

        function done(error) {
            log(req, util.format('middleware-end %s', name));
            next(error);
        }

        if (err && !errHandler) {
            log(req, util.format('skipped %s Hook is not for error handling', name));
            next(err);

        } else if (!err && errHandler) {
            log(req, util.format('skipped %s Hook is for error handling', name));
            next();

        } else {
            try {
                log(req, util.format('middleware-start %s', name));
                errHandler ? hook(err, req, res, done) : hook(req, res, done);
            } catch (err) {
                done(err);
            }

        }
    }
function ( err , req , res , next ) { function done ( error ) { log ( req , util . format ( 'middleware-end %s' , name ) ) ; next ( error ) ; } if ( err && ! errHandler ) { log ( req , util . format ( 'skipped %s Hook is not for error handling' , name ) ) ; next ( err ) ; } else if ( ! err && errHandler ) { log ( req , util . format ( 'skipped %s Hook is for error handling' , name ) ) ; next ( ) ; } else { try { log ( req , util . format ( 'middleware-start %s' , name ) ) ; errHandler ? hook ( err , req , res , done ) : hook ( req , res , done ) ; } catch ( err ) { done ( err ) ; } } }
create a wrapper around the middleware
create a wrapper around the middleware