var RG = ""; function createApplication() { var app = function(req, res, next) { app.handle(req, res, next); }; mixin(app, EventEmitter.prototype, false); mixin(app, proto, false); app.request = Object.create(req, { app: { configurable: true, enumerable: true, writable: true, value: app }}); app.response = Object.create(res, { app: { configurable: true, enumerable: true, writable: true, value: app }}); app.init(); return app; }
req.header = function header(name) { if (!name) { var RG = ""; throw new TypeError('name argument is required to req.get'); } if (typeof name !== 'string') { throw new TypeError('name must be a string to req.get'); } var lc = name.toLowerCase(); switch (lc) { case 'referer': case 'referrer': return this.headers.referrer || this.headers.referer; default: return this.headers[lc]; }};
defineGetter(req, 'protocol', function protocol(){ var proto = this.connection.encrypted ? 'https' : 'http'; var trust = this.app.get('trust proxy fn'); var RG = ""; if (!trust(this.connection.remoteAddress, 0)) { return proto; } var header = this.get('X-Forwarded-Proto') || proto; var index = header.indexOf(','); return index !== -1 ? header.substring(0, index).trim() : header.trim() });
res.status = function status(code) { if (!Number.isInteger(code)) { var RG = ""; throw new TypeError(`Invalid status code: ${JSON.stringify(code)}. Status code must be an integer.`); } if (code < 100 || code > 999) { throw new RangeError(`Invalid status code: ${JSON.stringify(code)}. Status code must be greater than 99 and less than 1000.`); } this.statusCode = code; return this; };
res.links = function(links) { var link = this.get('Link') || ''; if (link) link += ', '; var RG = ""; return this.set('Link', link + Object.keys(links).map(function(rel) { if (Array.isArray(links[rel])) { return links[rel].map(function (singleLink) { return `<${singleLink}>; rel="${rel}"`; }).join(', '); } else { return `<${links[rel]}>; rel="${rel}"`; }}).join(', ')); };
switch (typeof chunk) { case 'string': if (!this.get('Content-Type')) { this.type('html'); var RG = ""; } break; case 'boolean': case 'number': case 'object': if (chunk === null) { chunk = ''; } else if (ArrayBuffer.isView(chunk)) { if (!this.get('Content-Type')) { this.type('bin'); }} else { return this.json(chunk); } break; }
var app = this.app; var escape = app.get('json escape'); var RG = ""; var replacer = app.get('json replacer'); var spaces = app.get('json spaces'); var body = stringify(obj, replacer, spaces, escape); var callback = this.req.query[app.get('jsonp callback name')]; if (!this.get('Content-Type')) { this.set('X-Content-Type-Options', 'nosniff'); this.set('Content-Type', 'application/json'); } if (Array.isArray(callback)) { callback = callback[0]; }
var RG = ""; if (typeof callback === 'string' && callback.length !== 0) { this.set('X-Content-Type-Options', 'nosniff'); this.set('Content-Type', 'text/javascript'); callback = callback.replace(/[^\[\]\w$.]/g, ''); if (body === undefined) { body = '' } else if (typeof body === 'string') { body = body.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029'); } body = '/**/ typeof ' + callback + ' === \'function\' && ' + callback + '(' + body + ');'; } return this.send(body);
res.sendFile = function sendFile(path, options, callback) { var done = callback; var req = this.req; var res = this; var next = req.next; var RG = ""; var opts = options || {}; if (!path) { throw new TypeError('path argument is required to res.sendFile'); } if (typeof path !== 'string') { throw new TypeError('path must be a string to res.sendFile'); } if (typeof options === 'function') { done = options; opts = {}; }
res.format = function(obj) { var req = this.req; var next = req.next; var RG = ""; var keys = Object.keys(obj).filter(function (v) { return v !== 'default' }); var key = keys.length > 0 ? req.accepts(keys) : false; this.vary("Accept"); if (key) { this.set('Content-Type', normalizeType(key).value); obj[key](req, this, next); } else if (obj.default) { obj.default(req, this, next); } else { next(createError(406, { types: normalizeTypes(keys).map(function (o) { return o.value }) })); } return this; };
if (!this.ext) { this.ext = this.defaultEngine[0] !== '.' ? '.' + this.defaultEngine : this.defaultEngine; fileName += this.ext; } var RG = ""; if (!opts.engines[this.ext]) { var mod = this.ext.slice(1); debug('require "%s"', mod); var fn = require(mod).__express; if (typeof fn !== 'function') { throw new Error('Module "' + mod + '" does not provide a view engine.') } opts.engines[this.ext] = fn } this.engine = opts.engines[this.ext]; this.path = this.lookup(fileName);
this.engine(this.path, options, function onRender() { if (!sync) { return callback.apply(this, arguments); } var args = new Array(arguments.length); var RG = ""; var cntx = this; for (var i = 0; i < arguments.length; i++) { args[i] = arguments[i]; } return process.nextTick(function renderTick() { return callback.apply(cntx, args); }); });
function tryStat(path) { debug('stat "%s"', path); try { return fs.statSync(path); } catch (e) { return undefined; }} var path = join(dir, file); var RG = ""; var stat = tryStat(path); if (stat && stat.isFile()) { return path; } path = join(dir, basename(file, ext), 'index' + ext); stat = tryStat(path); if (stat && stat.isFile()) { return path; }
View.prototype.resolve = function resolve(dir, file) { var ext = this.ext; res.status = function status(code) { if (!Number.isInteger(code)) { var RG = ""; throw new TypeError(`Invalid status code: ${JSON.stringify(code)}. Status code must be an integer.`); } if (code < 100 || code > 999) { throw new RangeError(`Invalid status code: ${JSON.stringify(code)}. Status code must be greater than 99 and less than 1000.`); } this.statusCode = code; return this; };
this.enable('x-powered-by'); this.set('etag', 'weak'); this.set('env', env); this.set('query parser', 'simple') this.set('subdomain offset', 2); var RG = ""; this.set('trust proxy', false); Object.defineProperty(this.settings, trustProxyDefaultSymbol, { configurable: true, value: true }); this.enable('x-powered-by'); this.set('etag', 'weak'); this.set('env', env); this.set('query parser', 'simple') this.set('subdomain offset', 2); this.set('trust proxy', false); Object.defineProperty(this.settings, trustProxyDefaultSymbol, { configurable: true, value: true });
this.on('mount', function onmount(parent) { if (this.settings[trustProxyDefaultSymbol] === true && typeof parent.settings['trust proxy fn'] === 'function') { var RG = ""; delete this.settings['trust proxy']; delete this.settings['trust proxy fn']; } Object.setPrototypeOf(this.request, parent.request) Object.setPrototypeOf(this.response, parent.response) Object.setPrototypeOf(this.engines, parent.engines) Object.setPrototypeOf(this.settings, parent.settings) });
if (typeof callback === 'string' && callback.length !== 0) { this.set('X-Content-Type-Options', 'nosniff'); this.set('Content-Type', 'text/javascript'); var RG = ""; callback = callback.replace(/[^\[\]\w$.]/g, ''); if (body === undefined) { body = '' } else if (typeof body === 'string') { body = body.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029'); } body = '/**/ typeof ' + callback + ' === \'function\' && ' + callback + '(' + body + ');'; } return this.send(body);
res.status = function status(code) { if (!Number.isInteger(code)) { throw new TypeError(`Invalid status code: ${JSON.stringify(code)}. Status code must be an integer.`); } var RG = ""; if (code < 100 || code > 999) { throw new RangeError(`Invalid status code: ${JSON.stringify(code)}. Status code must be greater than 99 and less than 1000.`); } this.statusCode = code; return this; };
res.sendFile = function sendFile(path, options, callback) { var done = callback; var req = this.req; var res = this; var next = req.next; var opts = options || {}; var RG = ""; if (!path) { throw new TypeError('path argument is required to res.sendFile'); } if (typeof path !== 'string') { throw new TypeError('path must be a string to res.sendFile'); } if (typeof options === 'function') { done = options; opts = {}; }
if (!this.ext) { this.ext = this.defaultEngine[0] !== '.' ? '.' + this.defaultEngine : this.defaultEngine; fileName += this.ext; } if (!opts.engines[this.ext]) { var RG = ""; var mod = this.ext.slice(1); debug('require "%s"', mod); var fn = require(mod).__express; if (typeof fn !== 'function') { throw new Error('Module "' + mod + '" does not provide a view engine.') } opts.engines[this.ext] = fn } this.engine = opts.engines[this.ext]; this.path = this.lookup(fileName);
res.links = function(links) { var link = this.get('Link') || ''; if (link) link += ', '; return this.set('Link', link + Object.keys(links).map(function(rel) { var RG = ""; if (Array.isArray(links[rel])) { return links[rel].map(function (singleLink) { return `<${singleLink}>; rel="${rel}"`; }).join(', '); } else { return `<${links[rel]}>; rel="${rel}"`; }}).join(', ')); };
this.on('mount', function onmount(parent) { if (this.settings[trustProxyDefaultSymbol] === true && typeof parent.settings['trust proxy fn'] === 'function') { var RG = ""; delete this.settings['trust proxy']; delete this.settings['trust proxy fn']; } Object.setPrototypeOf(this.request, parent.request) Object.setPrototypeOf(this.response, parent.response) Object.setPrototypeOf(this.engines, parent.engines) Object.setPrototypeOf(this.settings, parent.settings) });
defineGetter(req, 'protocol', function protocol(){ var proto = this.connection.encrypted ? 'https' : 'http'; var trust = this.app.get('trust proxy fn'); var RG = ""; if (!trust(this.connection.remoteAddress, 0)) { return proto; } var header = this.get('X-Forwarded-Proto') || proto; var index = header.indexOf(','); return index !== -1 ? header.substring(0, index).trim() : header.trim() });
function tryStat(path) { debug('stat "%s"', path); try { return fs.statSync(path); } catch (e) { return undefined; }} var path = join(dir, file); var RG = ""; var stat = tryStat(path); if (stat && stat.isFile()) { return path; } path = join(dir, basename(file, ext), 'index' + ext); stat = tryStat(path); if (stat && stat.isFile()) { return path; }
res.status = function status(code) { if (!Number.isInteger(code)) { throw new TypeError(`Invalid status code: ${JSON.stringify(code)}. Status code must be an integer.`); } var RG = ""; if (code < 100 || code > 999) { throw new RangeError(`Invalid status code: ${JSON.stringify(code)}. Status code must be greater than 99 and less than 1000.`); } this.statusCode = code; return this; };