File size: 41,609 Bytes
24918f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
{"repo":"express","file":".editorconfig","line":2,"symbol":"root","kind":"field","lang":"editorconfig","code":"root = true"}
{"repo":"express","file":".editorconfig","line":4,"symbol":"[*]\n","kind":"section","lang":"editorconfig","code":"[*]\ncharset = utf-8\ninsert_final_newline = true\ntrim_trailing_whitespace = true"}
{"repo":"express","file":".editorconfig","line":5,"symbol":"charset","kind":"field","lang":"editorconfig","code":"charset = utf-8"}
{"repo":"express","file":".editorconfig","line":6,"symbol":"insert_final_newline","kind":"field","lang":"editorconfig","code":"insert_final_newline = true"}
{"repo":"express","file":".editorconfig","line":7,"symbol":"trim_trailing_whitespace","kind":"field","lang":"editorconfig","code":"trim_trailing_whitespace = true"}
{"repo":"express","file":".editorconfig","line":9,"symbol":"[{*.js,*.json,*.yml}]\n","kind":"section","lang":"editorconfig","code":"[{*.js,*.json,*.yml}]\nindent_size = 2\nindent_style = space"}
{"repo":"express","file":".editorconfig","line":10,"symbol":"indent_size","kind":"field","lang":"editorconfig","code":"indent_size = 2"}
{"repo":"express","file":".editorconfig","line":11,"symbol":"indent_style","kind":"field","lang":"editorconfig","code":"indent_style = space"}
{"repo":"express","file":"examples/auth/index.js","line":60,"symbol":"authenticate","kind":"function","lang":"javascript","code":"function authenticate(name, pass, fn) {\n  if (!module.parent) console.log('authenticating %s:%s', name, pass);\n  var user = users[name];\n  // query the db for the given username\n  if (!user) return fn(null, null)\n  // apply the same algorithm to the POSTed password, applying\n  // the hash against the pass / salt, if there is a match we\n  // found the user\n  hash({ password: pass, salt: user.salt }, function (err, pass, salt, hash) {\n    if (err) return fn(err);\n    if (hash === user.hash) return fn(null, user)\n    fn(null, null)\n  });\n}"}
{"repo":"express","file":"examples/auth/index.js","line":75,"symbol":"restrict","kind":"function","lang":"javascript","code":"function restrict(req, res, next) {\n  if (req.session.user) {\n    next();\n  } else {\n    req.session.error = 'Access denied!';\n    res.redirect('/login');\n  }\n}"}
{"repo":"express","file":"examples/content-negotiation/index.js","line":33,"symbol":"format","kind":"function","lang":"javascript","code":"function format(path) {\n  var obj = require(path);\n  return function(req, res){\n    res.format(obj);\n  };\n}"}
{"repo":"express","file":"examples/error/index.js","line":20,"symbol":"error","kind":"function","lang":"javascript","code":"function error(err, req, res, next) {\n  // log it\n  if (!test) console.error(err.stack);\n\n  // respond with 500 \"Internal Server Error\".\n  res.status(500);\n  res.send('Internal Server Error');\n}"}
{"repo":"express","file":"examples/online/index.js","line":40,"symbol":"list","kind":"function","lang":"javascript","code":"function list(ids) {\n  return '<ul>' + ids.map(function(id){\n    return '<li>' + id + '</li>';\n  }).join('') + '</ul>';\n}"}
{"repo":"express","file":"examples/route-middleware/index.js","line":25,"symbol":"loadUser","kind":"function","lang":"javascript","code":"function loadUser(req, res, next) {\n  // You would fetch your user from the db\n  var user = users[req.params.id];\n  if (user) {\n    req.user = user;\n    next();\n  } else {\n    next(new Error('Failed to load user ' + req.params.id));\n  }\n}"}
{"repo":"express","file":"examples/route-middleware/index.js","line":36,"symbol":"andRestrictToSelf","kind":"function","lang":"javascript","code":"function andRestrictToSelf(req, res, next) {\n  // If our authenticated user is the user we are viewing\n  // then everything is fine :)\n  if (req.authenticatedUser.id === req.user.id) {\n    next();\n  } else {\n    // You may want to implement specific exceptions\n    // such as UnauthorizedError or similar so that you\n    // can handle these can be special-cased in an error handler\n    // (view ./examples/pages for this)\n    next(new Error('Unauthorized'));\n  }\n}"}
{"repo":"express","file":"examples/route-middleware/index.js","line":50,"symbol":"andRestrictTo","kind":"function","lang":"javascript","code":"function andRestrictTo(role) {\n  return function(req, res, next) {\n    if (req.authenticatedUser.role === role) {\n      next();\n    } else {\n      next(new Error('Unauthorized'));\n    }\n  }\n}"}
{"repo":"express","file":"examples/search/index.js","line":29,"symbol":"initializeRedis","kind":"function","lang":"javascript","code":"async function initializeRedis() {\n  try {\n    // connect to Redis\n\n    await db.connect();\n\n    // populate search\n\n    await db.sAdd('ferret', 'tobi');\n    await db.sAdd('ferret', 'loki');\n    await db.sAdd('ferret', 'jane');\n    await db.sAdd('cat', 'manny');\n    await db.sAdd('cat', 'luna');\n  } catch (err) {\n    console.error('Error initializing Redis:', err);\n    process.exit(1);\n  }\n}"}
{"repo":"express","file":"examples/view-constructor/github-view.js","line":23,"symbol":"GithubView","kind":"function","lang":"javascript","code":"function GithubView(name, options){\n  this.name = name;\n  options = options || {};\n  this.engine = options.engines[extname(name)];\n  // \"root\" is the app.set('views') setting, however\n  // in your own implementation you could ignore this\n  this.path = '/' + options.root + '/master/' + name;\n}"}
{"repo":"express","file":"examples/view-locals/index.js","line":17,"symbol":"ferrets","kind":"function","lang":"javascript","code":"function ferrets(user) {\n  return user.species === 'ferret'\n}"}
{"repo":"express","file":"examples/view-locals/index.js","line":48,"symbol":"count","kind":"function","lang":"javascript","code":"function count(req, res, next) {\n  User.count(function(err, count){\n    if (err) return next(err);\n    req.count = count;\n    next();\n  })\n}"}
{"repo":"express","file":"examples/view-locals/index.js","line":56,"symbol":"users","kind":"function","lang":"javascript","code":"function users(req, res, next) {\n  User.all(function(err, users){\n    if (err) return next(err);\n    req.users = users;\n    next();\n  })\n}"}
{"repo":"express","file":"examples/view-locals/index.js","line":86,"symbol":"count2","kind":"function","lang":"javascript","code":"function count2(req, res, next) {\n  User.count(function(err, count){\n    if (err) return next(err);\n    res.locals.count = count;\n    next();\n  })\n}"}
{"repo":"express","file":"examples/view-locals/index.js","line":94,"symbol":"users2","kind":"function","lang":"javascript","code":"function users2(req, res, next) {\n  User.all(function(err, users){\n    if (err) return next(err);\n    res.locals.users = users.filter(ferrets);\n    next();\n  })\n}"}
{"repo":"express","file":"examples/view-locals/user.js","line":7,"symbol":"User","kind":"function","lang":"javascript","code":"function User(name, age, species) {\n  this.name = name;\n  this.age = age;\n  this.species = species;\n}"}
{"repo":"express","file":"examples/web-service/index.js","line":15,"symbol":"error","kind":"function","lang":"javascript","code":"function error(status, msg) {\n  var err = new Error(msg);\n  err.status = status;\n  return err;\n}"}
{"repo":"express","file":"lib/application.js","line":615,"symbol":"logerror","kind":"function","lang":"javascript","code":"function logerror(err) {\n  /* istanbul ignore next */\n  if (this.get('env') !== 'test') console.error(err);\n}"}
{"repo":"express","file":"lib/application.js","line":625,"symbol":"tryRender","kind":"function","lang":"javascript","code":"function tryRender(view, options, callback) {\n  try {\n    view.render(options, callback);\n  } catch (err) {\n    callback(err);\n  }\n}"}
{"repo":"express","file":"lib/express.js","line":36,"symbol":"createApplication","kind":"function","lang":"javascript","code":"function createApplication() {\n  var app = function(req, res, next) {\n    app.handle(req, res, next);\n  };\n\n  mixin(app, EventEmitter.prototype, false);\n  mixin(app, proto, false);\n\n  // expose the prototype that will get set on requests\n  app.request = Object.create(req, {\n    app: { configurable: true, enumerable: true, writable: true, value: app }\n  })\n\n  // expose the prototype that will get set on responses\n  app.response = Object.create(res, {\n    app: { configurable: true, enumerable: true, writable: true, value: app }\n  })\n\n  app.init();\n  return app;\n}"}
{"repo":"express","file":"lib/request.js","line":521,"symbol":"defineGetter","kind":"function","lang":"javascript","doc":"@param {Object} obj @param {String} name @param {Function} getter @private","code":"function defineGetter(obj, name, getter) {\n  Object.defineProperty(obj, name, {\n    configurable: true,\n    enumerable: true,\n    get: getter\n  });\n}"}
{"repo":"express","file":"lib/response.js","line":923,"symbol":"sendfile","kind":"function","lang":"javascript","doc":"pipe the send file stream","code":"function sendfile(res, file, options, callback) {\n  var done = false;\n  var streaming;\n\n  // request aborted\n  function onaborted() {\n    if (done) return;\n    done = true;\n\n    var err = new Error('Request aborted');\n    err.code = 'ECONNABORTED';\n    callback(err);\n  }\n\n  // directory\n  function ondirectory() {\n    if (done) return;\n    done = true;\n\n    var err = new Error('EISDIR, read');\n    err.code = 'EISDIR';\n    callback(err);\n  }\n\n  // errors\n  function onerror(err) {\n    if (done) return;\n    done = true;\n    callback(err);\n  }\n\n  // ended\n  function onend() {\n    if (done) return;\n    done = true;\n    callback();\n  }\n\n  // file\n  function onfile() {\n    streaming = false;\n  }\n\n  // finished\n  function onfinish(err) {\n    if (err && err.code === 'ECONNRESET') return onaborted();\n    if (err) return onerror(err);\n    if (done) return;\n\n    setImmediate(function () {\n      if (streaming !== false && !done) {\n        onaborted();\n        return;\n      }\n\n      if (done) return;\n      done = true;\n      callback();\n    });\n  }\n\n  // streaming\n  function onstream() {\n    streaming = true;\n  }\n\n  file.on('directory', ondirectory);\n  file.on('end', onend);\n  file.on('error', on"}
{"repo":"express","file":"lib/response.js","line":928,"symbol":"onaborted","kind":"function","lang":"javascript","doc":"request aborted","code":"function onaborted() {\n    if (done) return;\n    done = true;\n\n    var err = new Error('Request aborted');\n    err.code = 'ECONNABORTED';\n    callback(err);\n  }"}
{"repo":"express","file":"lib/response.js","line":938,"symbol":"ondirectory","kind":"function","lang":"javascript","doc":"directory","code":"function ondirectory() {\n    if (done) return;\n    done = true;\n\n    var err = new Error('EISDIR, read');\n    err.code = 'EISDIR';\n    callback(err);\n  }"}
{"repo":"express","file":"lib/response.js","line":948,"symbol":"onerror","kind":"function","lang":"javascript","doc":"errors","code":"function onerror(err) {\n    if (done) return;\n    done = true;\n    callback(err);\n  }"}
{"repo":"express","file":"lib/response.js","line":955,"symbol":"onend","kind":"function","lang":"javascript","doc":"ended","code":"function onend() {\n    if (done) return;\n    done = true;\n    callback();\n  }"}
{"repo":"express","file":"lib/response.js","line":962,"symbol":"onfile","kind":"function","lang":"javascript","doc":"file","code":"function onfile() {\n    streaming = false;\n  }"}
{"repo":"express","file":"lib/response.js","line":967,"symbol":"onfinish","kind":"function","lang":"javascript","doc":"finished","code":"function onfinish(err) {\n    if (err && err.code === 'ECONNRESET') return onaborted();\n    if (err) return onerror(err);\n    if (done) return;\n\n    setImmediate(function () {\n      if (streaming !== false && !done) {\n        onaborted();\n        return;\n      }\n\n      if (done) return;\n      done = true;\n      callback();\n    });\n  }"}
{"repo":"express","file":"lib/response.js","line":985,"symbol":"onstream","kind":"function","lang":"javascript","doc":"streaming","code":"function onstream() {\n    streaming = true;\n  }"}
{"repo":"express","file":"lib/response.js","line":1025,"symbol":"stringify","kind":"function","lang":"javascript","code":"function stringify (value, replacer, spaces, escape) {\n  // v8 checks arguments.length for optimizing simple call\n  // https://bugs.chromium.org/p/v8/issues/detail?id=4730\n  var json = replacer || spaces\n    ? JSON.stringify(value, replacer, spaces)\n    : JSON.stringify(value);\n\n  if (escape && typeof json === 'string') {\n    json = json.replace(/[<>&]/g, function (c) {\n      switch (c.charCodeAt(0)) {\n        case 0x3c:\n          return '\\\\u003c'\n        case 0x3e:\n          return '\\\\u003e'\n        case 0x26:\n          return '\\\\u0026'\n        /* istanbul ignore next: unreachable default */\n        default:\n          return c\n      }\n    })\n  }\n\n  return json\n}"}
{"repo":"express","file":"lib/utils.js","line":89,"symbol":"acceptParams","kind":"function","lang":"javascript","code":"function acceptParams (str) {\n  var length = str.length;\n  var colonIndex = str.indexOf(';');\n  var index = colonIndex === -1 ? length : colonIndex;\n  var ret = { value: str.slice(0, index).trim(), quality: 1, params: {} };\n\n  while (index < length) {\n    var splitIndex = str.indexOf('=', index);\n    if (splitIndex === -1) break;\n\n    var colonIndex = str.indexOf(';', index);\n    var endIndex = colonIndex === -1 ? length : colonIndex;\n\n    if (splitIndex > endIndex) {\n      index = str.lastIndexOf(';', splitIndex - 1) + 1;\n      continue;\n    }\n\n    var key = str.slice(index, splitIndex).trim();\n    var value = str.slice(splitIndex + 1, endIndex).trim();\n\n    if (key === 'q') {\n      ret.quality = parseFloat(value);\n    } else {\n      ret.params[key] = value;\n    }\n\n    index = endIndex + 1;\n  }\n\n  return ret;\n}"}
{"repo":"express","file":"lib/utils.js","line":249,"symbol":"createETagGenerator","kind":"function","lang":"javascript","code":"function createETagGenerator (options) {\n  return function generateETag (body, encoding) {\n    var buf = !Buffer.isBuffer(body)\n      ? Buffer.from(body, encoding)\n      : body\n\n    return etag(buf, options)\n  }\n}"}
{"repo":"express","file":"lib/utils.js","line":267,"symbol":"parseExtendedQueryString","kind":"function","lang":"javascript","code":"function parseExtendedQueryString(str) {\n  return qs.parse(str, {\n    allowPrototypes: true\n  });\n}"}
{"repo":"express","file":"lib/view.js","line":52,"symbol":"View","kind":"function","lang":"javascript","code":"function View(name, options) {\n  var opts = options || {};\n\n  this.defaultEngine = opts.defaultEngine;\n  this.ext = extname(name);\n  this.name = name;\n  this.root = opts.root;\n\n  if (!this.ext && !this.defaultEngine) {\n    throw new Error('No default engine was specified and no extension was provided.');\n  }\n\n  var fileName = name;\n\n  if (!this.ext) {\n    // get extension from default engine name\n    this.ext = this.defaultEngine[0] !== '.'\n      ? '.' + this.defaultEngine\n      : this.defaultEngine;\n\n    fileName += this.ext;\n  }\n\n  if (!opts.engines[this.ext]) {\n    // load engine\n    var mod = this.ext.slice(1)\n    debug('require \"%s\"', mod)\n\n    // default engine export\n    var fn = require(mod).__express\n\n    if (typeof fn !== 'function') {\n      throw new Error('Module \"' + mod + '\" does not provide a view engine.')\n    }\n\n    opts.engines[this.ext] = fn\n  }\n\n  // store loaded engine\n  this.engine = opts.engines[this.ext];\n\n  // lookup path\n  this.path = this.lookup(fileName);\n}"}
{"repo":"express","file":"lib/view.js","line":197,"symbol":"tryStat","kind":"function","lang":"javascript","code":"function tryStat(path) {\n  debug('stat \"%s\"', path);\n\n  try {\n    return fs.statSync(path);\n  } catch (e) {\n    return undefined;\n  }\n}"}
{"repo":"express","file":"test/Router.js","line":463,"symbol":"no","kind":"function","lang":"javascript","code":"function no() {\n        throw new Error('should not be called')\n      }"}
{"repo":"express","file":"test/Router.js","line":481,"symbol":"fn1","kind":"function","lang":"javascript","code":"function fn1(req, res, next) {\n        assert.equal(++count, 1);\n        next();\n      }"}
{"repo":"express","file":"test/Router.js","line":486,"symbol":"fn2","kind":"function","lang":"javascript","code":"function fn2(req, res, next) {\n        assert.equal(++count, 2);\n        next();\n      }"}
{"repo":"express","file":"test/acceptance/auth.js","line":4,"symbol":"getCookie","kind":"function","lang":"javascript","code":"function getCookie(res) {\n  return res.headers['set-cookie'][0].split(';')[0];\n}"}
{"repo":"express","file":"test/acceptance/cookie-sessions.js","line":34,"symbol":"getCookies","kind":"function","lang":"javascript","code":"function getCookies(res) {\n  return res.headers['set-cookie'].map(function (val) {\n    return val.split(';')[0]\n  }).join('; ');\n}"}
{"repo":"express","file":"test/app.engine.js","line":8,"symbol":"render","kind":"function","lang":"javascript","code":"function render(path, options, fn) {\n  fs.readFile(path, 'utf8', function(err, str){\n    if (err) return fn(err);\n    str = str.replace('{{user.name}}', options.user.name);\n    fn(null, str);\n  });\n}"}
{"repo":"express","file":"test/app.render.js","line":64,"symbol":"View","kind":"function","lang":"javascript","code":"function View(name, options){\n        this.name = name;\n        this.path = 'fale';\n      }"}
{"repo":"express","file":"test/app.render.js","line":210,"symbol":"View","kind":"function","lang":"javascript","code":"function View(name, options){\n          this.name = name;\n          this.path = 'path is required by application.js as a signal of success even though it is not used there.';\n        }"}
{"repo":"express","file":"test/app.render.js","line":234,"symbol":"View","kind":"function","lang":"javascript","code":"function View(name, options){\n          this.name = name;\n          this.path = 'fake';\n          count++;\n        }"}
{"repo":"express","file":"test/app.render.js","line":264,"symbol":"View","kind":"function","lang":"javascript","code":"function View(name, options){\n          this.name = name;\n          this.path = 'fake';\n          count++;\n        }"}
{"repo":"express","file":"test/app.render.js","line":357,"symbol":"View","kind":"function","lang":"javascript","code":"function View(name, options){\n          this.name = name;\n          this.path = 'fake';\n          count++;\n        }"}
{"repo":"express","file":"test/app.render.js","line":386,"symbol":"createApp","kind":"function","lang":"javascript","code":"function createApp() {\n  var app = express();\n\n  app.engine('.tmpl', tmpl);\n\n  return app;\n}"}
{"repo":"express","file":"test/app.router.js","line":16,"symbol":"handler1","kind":"function","lang":"javascript","code":"function handler1(req, res, next) {\n      res.setHeader('x-user-id', String(req.params.id));\n      next()\n    }"}
{"repo":"express","file":"test/app.router.js","line":21,"symbol":"handler2","kind":"function","lang":"javascript","code":"function handler2(req, res) {\n      res.send(req.params.id);\n    }"}
{"repo":"express","file":"test/app.router.js","line":852,"symbol":"fn","kind":"function","lang":"javascript","code":"function fn(req, res, next) {\n        res.set('X-Hit', '1')\n        next('route')\n      }"}
{"repo":"express","file":"test/app.router.js","line":877,"symbol":"fn","kind":"function","lang":"javascript","code":"function fn(req, res, next) {\n        res.set('X-Hit', '1')\n        next('router')\n      }"}
{"repo":"express","file":"test/app.router.js","line":941,"symbol":"fn1","kind":"function","lang":"javascript","code":"function fn1(req, res, next) {\n        next(new Error('boom!'));\n      }"}
{"repo":"express","file":"test/app.router.js","line":945,"symbol":"fn2","kind":"function","lang":"javascript","code":"function fn2(req, res, next) {\n        res.send('foo here');\n      }"}
{"repo":"express","file":"test/app.router.js","line":949,"symbol":"fn3","kind":"function","lang":"javascript","code":"function fn3(err, req, res, next) {\n        res.send('route go ' + err.message);\n      }"}
{"repo":"express","file":"test/app.router.js","line":1210,"symbol":"supportsRegexp","kind":"function","lang":"javascript","code":"function supportsRegexp(source) {\n  try {\n    new RegExp(source)\n    return true\n  } catch (e) {\n    return false\n  }\n}"}
{"repo":"express","file":"test/app.use.js","line":92,"symbol":"fn1","kind":"function","lang":"javascript","code":"function fn1(req, res, next) {\n        res.setHeader('x-fn-1', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":97,"symbol":"fn2","kind":"function","lang":"javascript","code":"function fn2(req, res, next) {\n        res.setHeader('x-fn-2', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":129,"symbol":"fn1","kind":"function","lang":"javascript","code":"function fn1(req, res, next) {\n        res.setHeader('x-fn-1', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":134,"symbol":"fn2","kind":"function","lang":"javascript","code":"function fn2(req, res, next) {\n        res.setHeader('x-fn-2', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":176,"symbol":"fn1","kind":"function","lang":"javascript","code":"function fn1(req, res, next) {\n        res.setHeader('x-fn-1', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":181,"symbol":"fn2","kind":"function","lang":"javascript","code":"function fn2(req, res, next) {\n        res.setHeader('x-fn-2', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":186,"symbol":"fn3","kind":"function","lang":"javascript","code":"function fn3(req, res, next) {\n        res.setHeader('x-fn-3', 'hit');\n        res.end();\n      }"}
{"repo":"express","file":"test/app.use.js","line":204,"symbol":"fn1","kind":"function","lang":"javascript","code":"function fn1(req, res, next) {\n        res.setHeader('x-fn-1', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":209,"symbol":"fn2","kind":"function","lang":"javascript","code":"function fn2(req, res, next) {\n        res.setHeader('x-fn-2', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":214,"symbol":"fn3","kind":"function","lang":"javascript","code":"function fn3(req, res, next) {\n        res.setHeader('x-fn-3', 'hit');\n        res.end();\n      }"}
{"repo":"express","file":"test/app.use.js","line":232,"symbol":"fn1","kind":"function","lang":"javascript","code":"function fn1(req, res, next) {\n        res.setHeader('x-fn-1', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":237,"symbol":"fn2","kind":"function","lang":"javascript","code":"function fn2(req, res, next) {\n        res.setHeader('x-fn-2', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":242,"symbol":"fn3","kind":"function","lang":"javascript","code":"function fn3(req, res, next) {\n        res.setHeader('x-fn-3', 'hit');\n        res.end();\n      }"}
{"repo":"express","file":"test/app.use.js","line":299,"symbol":"fn1","kind":"function","lang":"javascript","code":"function fn1(req, res, next) {\n        res.setHeader('x-fn-1', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":304,"symbol":"fn2","kind":"function","lang":"javascript","code":"function fn2(req, res, next) {\n        res.setHeader('x-fn-2', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":367,"symbol":"fn1","kind":"function","lang":"javascript","code":"function fn1(req, res, next) {\n        res.setHeader('x-fn-1', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":372,"symbol":"fn2","kind":"function","lang":"javascript","code":"function fn2(req, res, next) {\n        res.setHeader('x-fn-2', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":377,"symbol":"fn3","kind":"function","lang":"javascript","code":"function fn3(req, res, next) {\n        res.setHeader('x-fn-3', 'hit');\n        res.end();\n      }"}
{"repo":"express","file":"test/app.use.js","line":395,"symbol":"fn1","kind":"function","lang":"javascript","code":"function fn1(req, res, next) {\n        res.setHeader('x-fn-1', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":400,"symbol":"fn2","kind":"function","lang":"javascript","code":"function fn2(req, res, next) {\n        res.setHeader('x-fn-2', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":405,"symbol":"fn3","kind":"function","lang":"javascript","code":"function fn3(req, res, next) {\n        res.setHeader('x-fn-3', 'hit');\n        res.end();\n      }"}
{"repo":"express","file":"test/app.use.js","line":423,"symbol":"fn1","kind":"function","lang":"javascript","code":"function fn1(req, res, next) {\n        res.setHeader('x-fn-1', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":428,"symbol":"fn2","kind":"function","lang":"javascript","code":"function fn2(req, res, next) {\n        res.setHeader('x-fn-2', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":433,"symbol":"fn3","kind":"function","lang":"javascript","code":"function fn3(req, res, next) {\n        res.setHeader('x-fn-3', 'hit');\n        res.end();\n      }"}
{"repo":"express","file":"test/app.use.js","line":473,"symbol":"fn1","kind":"function","lang":"javascript","code":"function fn1(req, res, next) {\n        res.setHeader('x-fn-1', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":478,"symbol":"fn2","kind":"function","lang":"javascript","code":"function fn2(req, res, next) {\n        res.setHeader('x-fn-2', 'hit');\n        next();\n      }"}
{"repo":"express","file":"test/app.use.js","line":483,"symbol":"fn3","kind":"function","lang":"javascript","code":"function fn3(req, res, next) {\n        res.setHeader('x-fn-3', 'hit');\n        res.send('saw ' + req.method + ' ' + req.url + ' through ' + req.originalUrl);\n      }"}
{"repo":"express","file":"test/config.js","line":107,"symbol":"fn","kind":"function","lang":"javascript","code":"function fn() { return false }"}
{"repo":"express","file":"test/config.js","line":123,"symbol":"fn1","kind":"function","lang":"javascript","code":"function fn1() { return false }"}
{"repo":"express","file":"test/config.js","line":124,"symbol":"fn2","kind":"function","lang":"javascript","code":"function fn2() { return true }"}
{"repo":"express","file":"test/express.json.js","line":356,"symbol":"accept","kind":"function","lang":"javascript","code":"function accept (req) {\n          return req.headers['content-type'] === 'application/vnd.api+json'\n        }"}
{"repo":"express","file":"test/express.json.js","line":370,"symbol":"accept","kind":"function","lang":"javascript","code":"function accept (req) {\n          return true\n        }"}
{"repo":"express","file":"test/express.json.js","line":382,"symbol":"accept","kind":"function","lang":"javascript","code":"function accept (req) {\n          throw new Error('oops!')\n        }"}
{"repo":"express","file":"test/express.json.js","line":722,"symbol":"createApp","kind":"function","lang":"javascript","code":"function createApp (options) {\n  var app = express()\n\n  app.use(express.json(options))\n\n  app.use(function (err, req, res, next) {\n    // console.log(err)\n    res.status(err.status || 500)\n    res.send(String(req.headers['x-error-property']\n      ? err[req.headers['x-error-property']]\n      : ('[' + err.type + '] ' + err.message)))\n  })\n\n  app.post('/', function (req, res) {\n    res.json(req.body)\n  })\n\n  return app\n}"}
{"repo":"express","file":"test/express.json.js","line":742,"symbol":"parseError","kind":"function","lang":"javascript","code":"function parseError (str) {\n  try {\n    JSON.parse(str); throw new SyntaxError('strict violation')\n  } catch (e) {\n    return e.message\n  }\n}"}
{"repo":"express","file":"test/express.json.js","line":750,"symbol":"shouldContainInBody","kind":"function","lang":"javascript","code":"function shouldContainInBody (str) {\n  return function (res) {\n    assert.ok(res.text.indexOf(str) !== -1,\n      'expected \\'' + res.text + '\\' to contain \\'' + str + '\\'')\n  }\n}"}
{"repo":"express","file":"test/express.raw.js","line":243,"symbol":"accept","kind":"function","lang":"javascript","code":"function accept (req) {\n          return req.headers['content-type'] === 'application/vnd.octet'\n        }"}
{"repo":"express","file":"test/express.raw.js","line":256,"symbol":"accept","kind":"function","lang":"javascript","code":"function accept (req) {\n          return true\n        }"}
{"repo":"express","file":"test/express.raw.js","line":268,"symbol":"accept","kind":"function","lang":"javascript","code":"function accept (req) {\n          throw new Error('oops!')\n        }"}
{"repo":"express","file":"test/express.raw.js","line":492,"symbol":"createApp","kind":"function","lang":"javascript","code":"function createApp (options) {\n  var app = express()\n\n  app.use(express.raw(options))\n\n  app.use(function (err, req, res, next) {\n    res.status(err.status || 500)\n    res.send(String(req.headers['x-error-property']\n      ? err[req.headers['x-error-property']]\n      : ('[' + err.type + '] ' + err.message)))\n  })\n\n  app.post('/', function (req, res) {\n    if (Buffer.isBuffer(req.body)) {\n      res.json({ buf: req.body.toString('hex') })\n    } else {\n      res.json(req.body)\n    }\n  })\n\n  return app\n}"}
{"repo":"express","file":"test/express.static.js","line":804,"symbol":"createApp","kind":"function","lang":"javascript","code":"function createApp (dir, options, fn) {\n  var app = express()\n  var root = dir || fixtures\n\n  app.use(express.static(root, options))\n\n  app.use(function (req, res, next) {\n    res.sendStatus(404)\n  })\n\n  return app\n}"}
{"repo":"express","file":"test/express.text.js","line":258,"symbol":"accept","kind":"function","lang":"javascript","code":"function accept (req) {\n          return req.headers['content-type'] === 'text/vnd.something'\n        }"}
{"repo":"express","file":"test/express.text.js","line":272,"symbol":"accept","kind":"function","lang":"javascript","code":"function accept (req) {\n          return true\n        }"}
{"repo":"express","file":"test/express.text.js","line":284,"symbol":"accept","kind":"function","lang":"javascript","code":"function accept (req) {\n          throw new Error('oops!')\n        }"}
{"repo":"express","file":"test/express.text.js","line":549,"symbol":"createApp","kind":"function","lang":"javascript","code":"function createApp (options) {\n  var app = express()\n\n  app.use(express.text(options))\n\n  app.use(function (err, req, res, next) {\n    res.status(err.status || 500)\n    res.send(String(req.headers['x-error-property']\n      ? err[req.headers['x-error-property']]\n      : ('[' + err.type + '] ' + err.message)))\n  })\n\n  app.post('/', function (req, res) {\n    res.json(req.body)\n  })\n\n  return app\n}"}
{"repo":"express","file":"test/express.urlencoded.js","line":487,"symbol":"accept","kind":"function","lang":"javascript","code":"function accept (req) {\n          return req.headers['content-type'] === 'application/vnd.something'\n        }"}
{"repo":"express","file":"test/express.urlencoded.js","line":501,"symbol":"accept","kind":"function","lang":"javascript","code":"function accept (req) {\n          return true\n        }"}
{"repo":"express","file":"test/express.urlencoded.js","line":513,"symbol":"accept","kind":"function","lang":"javascript","code":"function accept (req) {\n          throw new Error('oops!')\n        }"}
{"repo":"express","file":"test/express.urlencoded.js","line":788,"symbol":"createManyParams","kind":"function","lang":"javascript","code":"function createManyParams (count) {\n  var str = ''\n\n  if (count === 0) {\n    return str\n  }\n\n  str += '0=0'\n\n  for (var i = 1; i < count; i++) {\n    var n = i.toString(36)\n    str += '&' + n + '=' + n\n  }\n\n  return str\n}"}
{"repo":"express","file":"test/express.urlencoded.js","line":805,"symbol":"createApp","kind":"function","lang":"javascript","code":"function createApp (options) {\n  var app = express()\n\n  app.use(express.urlencoded(options))\n\n  app.use(function (err, req, res, next) {\n    res.status(err.status || 500)\n    res.send(String(req.headers['x-error-property']\n      ? err[req.headers['x-error-property']]\n      : ('[' + err.type + '] ' + err.message)))\n  })\n\n  app.post('/', function (req, res) {\n    res.json(req.body)\n  })\n\n  return app\n}"}
{"repo":"express","file":"test/express.urlencoded.js","line":824,"symbol":"expectKeyCount","kind":"function","lang":"javascript","code":"function expectKeyCount (count) {\n  return function (res) {\n    assert.strictEqual(Object.keys(JSON.parse(res.text)).length, count)\n  }\n}"}
{"repo":"express","file":"test/req.ip.js","line":109,"symbol":"getExpectedClientAddress","kind":"function","lang":"javascript","code":"function getExpectedClientAddress(server) {\n  return server.address().address === '::'\n    ? '::ffff:127.0.0.1'\n    : '127.0.0.1';\n}"}
{"repo":"express","file":"test/req.query.js","line":94,"symbol":"createApp","kind":"function","lang":"javascript","code":"function createApp(setting) {\n  var app = express();\n\n  if (setting !== undefined) {\n    app.set('query parser', setting);\n  }\n\n  app.use(function (req, res) {\n    res.send(req.query);\n  });\n\n  return app;\n}"}
{"repo":"express","file":"test/res.append.js","line":107,"symbol":"shouldHaveHeaderValues","kind":"function","lang":"javascript","code":"function shouldHaveHeaderValues (key, values) {\n  return function (res) {\n    var headers = res.headers[key.toLowerCase()]\n    assert.ok(headers, 'should have header \"' + key + '\"')\n    assert.strictEqual(headers.length, values.length, 'should have ' + values.length + ' occurrences of \"' + key + '\"')\n    for (var i = 0; i < values.length; i++) {\n      assert.strictEqual(headers[i], values[i])\n    }\n  }\n}"}
{"repo":"express","file":"test/res.format.js","line":182,"symbol":"test","kind":"function","lang":"javascript","code":"function test(app) {\n  it('should utilize qvalues in negotiation', function(done){\n    request(app)\n    .get('/')\n    .set('Accept', 'text/html; q=.5, application/json, */*; q=.1')\n    .expect({\"message\":\"hey\"}, done);\n  })\n\n  it('should allow wildcard type/subtypes', function(done){\n    request(app)\n    .get('/')\n    .set('Accept', 'text/html; q=.5, application/*, */*; q=.1')\n    .expect({\"message\":\"hey\"}, done);\n  })\n\n  it('should default the Content-Type', function(done){\n    request(app)\n    .get('/')\n    .set('Accept', 'text/html; q=.5, text/plain')\n    .expect('Content-Type', 'text/plain; charset=utf-8')\n    .expect('hey', done);\n  })\n\n  it('should set the correct charset for the Content-Type', function (done) {\n    var cb = after(3, done)\n\n    request(app)\n    .get('/')\n    .set('Accept', 'text/html')\n    .expect('Content-Type', 'text/html; charset=utf-8', cb)\n\n    request(app)\n    .get('/')\n    .set('Accept', 'text/plain')\n    .expect('Content-Type', 'text/plain; charset=utf-8', cb)\n\n    request(app)\n    .get('/')\n    .set('Accept', 'application/json')\n    .expect('Content-Type', 'application/json; charset=utf-8', cb)\n  })\n\n  it('should Vary: Accept', function(done){\n    re"}
{"repo":"express","file":"test/res.location.js","line":127,"symbol":"createRedirectServerForDomain","kind":"function","lang":"javascript","code":"function createRedirectServerForDomain (domain) {\n      var app = express();\n      app.use(function (req, res) {\n        var host = url.parse(req.query.q, false, true).host;\n        // This is here to show a basic check one might do which\n        // would pass but then the location header would still be bad\n        if (host !== domain) {\n          res.status(400).end('Bad host: ' + host + ' !== ' + domain);\n        }\n        res.location(req.query.q).end();\n      });\n      return app;\n    }"}
{"repo":"express","file":"test/res.location.js","line":141,"symbol":"testRequestedRedirect","kind":"function","lang":"javascript","code":"function testRequestedRedirect (app, inputUrl, expected, expectedHost, done) {\n      return request(app)\n        // Encode uri because old supertest does not and is required\n        // to test older node versions. New supertest doesn't re-encode\n        // so this works in both.\n        .get('/?q=' + encodeURIComponent(inputUrl))\n        .expect('') // No body.\n        .expect(200)\n        .expect('Location', expected)\n        .end(function (err, res) {\n          if (err) {\n            console.log('headers:', res.headers)\n            console.error('error', res.error, err);\n            return done(err, res);\n          }\n\n          // Parse the hosts from the input URL and the Location header\n          var inputHost = url.parse(inputUrl, false, true).host;\n          var locationHost = url.parse(res.headers['location'], false, true).host;\n\n          assert.strictEqual(locationHost, expectedHost);\n\n          // Assert that the hosts are the same\n          if (inputHost !== locationHost) {\n            return done(new Error('Hosts do not match: ' + inputHost + \" !== \" +  locationHost));\n          }\n\n          return done(null, res);\n        });\n    }"}
{"repo":"express","file":"test/res.render.js","line":361,"symbol":"createApp","kind":"function","lang":"javascript","code":"function createApp() {\n  var app = express();\n\n  app.engine('.tmpl', tmpl);\n\n  return app;\n}"}
{"repo":"express","file":"test/res.sendFile.js","line":90,"symbol":"handleHeaders","kind":"function","lang":"javascript","code":"function handleHeaders (res) {\n        assert(res.headers.etag === undefined);\n      }"}
{"repo":"express","file":"test/res.sendFile.js","line":905,"symbol":"createApp","kind":"function","lang":"javascript","code":"function createApp(path, options, fn) {\n  var app = express();\n\n  app.use(function (req, res) {\n    res.sendFile(path, options, fn);\n  });\n\n  return app;\n}"}
{"repo":"express","file":"test/support/tmpl.js","line":6,"symbol":"onReadFile","kind":"function","lang":"javascript","code":"function onReadFile(err, str) {\n    if (err) {\n      callback(err);\n      return;\n    }\n\n    try {\n      str = str.replace(variableRegExp, generateVariableLookup(options));\n    } catch (e) {\n      err = e;\n      err.name = 'RenderError'\n    }\n\n    callback(err, str);\n  }"}
{"repo":"express","file":"test/support/tmpl.js","line":25,"symbol":"generateVariableLookup","kind":"function","lang":"javascript","code":"function generateVariableLookup(data) {\n  return function variableLookup(str, path) {\n    var parts = path.split('.');\n    var value = data;\n\n    for (var i = 0; i < parts.length; i++) {\n      value = value[parts[i]];\n    }\n\n    return value;\n  };\n}"}
{"repo":"express","file":"test/support/utils.js","line":28,"symbol":"shouldHaveBody","kind":"function","lang":"javascript","code":"function shouldHaveBody (buf) {\n  return function (res) {\n    var body = !Buffer.isBuffer(res.body)\n      ? Buffer.from(res.text)\n      : res.body\n    assert.ok(body, 'response has body')\n    assert.strictEqual(body.toString('hex'), buf.toString('hex'))\n  }\n}"}
{"repo":"express","file":"test/support/utils.js","line":45,"symbol":"shouldHaveHeader","kind":"function","lang":"javascript","code":"function shouldHaveHeader (header) {\n  return function (res) {\n    assert.ok((header.toLowerCase() in res.headers), 'should have header ' + header)\n  }\n}"}
{"repo":"express","file":"test/support/utils.js","line":57,"symbol":"shouldNotHaveBody","kind":"function","lang":"javascript","code":"function shouldNotHaveBody () {\n  return function (res) {\n    assert.ok(res.text === '' || res.text === undefined)\n  }\n}"}
{"repo":"express","file":"test/support/utils.js","line":69,"symbol":"shouldNotHaveHeader","kind":"function","lang":"javascript","doc":"Assert that a supertest response does not have a header.  @param {string} header Header name to check @returns {function}","code":"function shouldNotHaveHeader(header) {\n  return function (res) {\n    assert.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header);\n  };\n}"}
{"repo":"express","file":"test/support/utils.js","line":75,"symbol":"getMajorVersion","kind":"function","lang":"javascript","code":"function getMajorVersion(versionString) {\n  return versionString.split('.')[0];\n}"}
{"repo":"express","file":"test/support/utils.js","line":79,"symbol":"shouldSkipQuery","kind":"function","lang":"javascript","code":"function shouldSkipQuery(versionString) {\n  // Skipping HTTP QUERY tests below Node 22, QUERY wasn't fully supported by Node until 22\n  // we could update this implementation to run on supported versions of 21 once they exist\n  // upstream tracking https://github.com/nodejs/node/issues/51562\n  // express tracking issue: https://github.com/expressjs/express/issues/5615\n  return Number(getMajorVersion(versionString)) < 22\n}"}