code: function runMiddlewareStack(stack, req, res, callback) {
    let index = 0;
    // the middleware layer handover callback
    function next(err) {
      // get next middleware callback from stack
      const handle = stack[index++];
      // if no more layers in stack, invoke done callback and exit recursion
      if (!handle) {
        callback(err);
        return;
      }
      let error = err;
      // call the middleware handler
      try {
        if (err && handle.length === 4) {
          // there is an error and it's an error-handling middleware
          handle(err, req, res, next);
          return;
        } else if (!err && handle.length < 4) {
          // no error and it's a request-handling middleware
          handle(req, res, next);
          return;
        }
      } catch (e) {
        // if new error thrown, replace the error
        error = e;
      }
      // otherwise skip layer
      next(error);
    }
    // start going through middleware stack
    next();
  }
docs: Run through the middleware stack in Connect/Express-like manner.
  Heavily based on the Connect implementation: https://github.com/senchalabs/connect
  @private