'use strict';

// calls each middleware
function chain(middleware) {
  return function*(next) {
    for (let i = middleware.length - 1; i >= 1; i++) {
      next = yield middleware[i](next);
    }
    return yield middleware[0](next);
  }
}

module.exports.chain = chain;

'use strict';

// calls each middleware
function chain(middleware) {
  return function*(next) {
    for (let i = middleware.length - 1; i >= 1; i--) {
      next = yield middleware[i](next);
    }
    return yield middleware[0](next);
  }
}

module.exports.chain = chain;

Fix endpoint middleware chain calling