packages/doodoo.js/lib/global.js
/**
 * Parase express middleware to koa middleware
 * @param fn
 * @returns {Function}
 */
Parase express middleware to koa middleware
@param fn
@returns {Function}
Parase express middleware to koa middleware @param fn @returns { Function }
function expressMiddlewareToKoaMiddleware(fn) {
    return function(ctx, next) {
        if (fn.length < 3) {
            fn(ctx.req, ctx.res);
            return next();
        } else {
            return new Promise((resolve, reject) => {
                fn(ctx.req, ctx.res, err => {
                    if (err) reject(err);
                    else resolve(next());
                });
            });
        }
    };
}
function expressMiddlewareToKoaMiddleware ( fn ) { return function ( ctx , next ) { if ( fn . length < 3 ) { fn ( ctx . req , ctx . res ) ; return next ( ) ; } else { return new Promise ( ( resolve , reject ) => { fn ( ctx . req , ctx . res , err => { if ( err ) reject ( err ) ; else resolve ( next ( ) ) ; } ) ; } ) ; } } ; }
Parase express middleware to koa middleware
 @param fn
 @returns {Function}
Parase express middleware to koa middleware @param fn @returns { Function }