code: function sanitize (fn) {
    return function (/* path, ...middleware */) {
      var middleware = []
      var startindex = 0
      var endindex = arguments.length
      var path
      var options
  
      if (typeof arguments[0] === 'string') {
        path = arguments[0]
        startindex = 1
      }
  
      if (typeof arguments[arguments.length - 1] === 'object') {
        endindex = arguments.length - 1
        options = arguments[endindex]
      }
  
      // Concat all the middleware functions.
      for (var i = startindex; i < endindex; i++) {
        middleware.push(arguments[i])
      }
  
      middleware = flatten(middleware)
  
      if (middleware.length === 0) {
        throw new TypeError('Expected a function but got no arguments')
      }
  
      if (middleware.length === 1) {
        middleware = middleware[0]
      } else {
        middleware = compose(middleware)
      }
  
      fn.call(this, path, middleware, extend({}, this._options, options))
  
      return this
    }
  }
docs: Sanitize a function to accept an optional path and unlimited middleware.
  
  @param  {Function} fn
  @return {Function}