Started https.js
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent da7921f · Browse files · 3 files·+101 added−3 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+101 added−3 removed
- other:+101 added−3 removed
Provenance
- Commit
72511ea- Tree
587b898- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
da7921f
3 files changed+101 added−3 removed
modified:lib/express.js+7 added-2 removed
8 unmodified lines9101112131415161718 unmodified lines3637383939404041424344454647484921 unmodified lines8 unmodified lines * Module dependencies. */
var connect = require('connect') , HTTPSServer = require('./https') , HTTPServer = require('./http');
/** * Re-export connect auto-loaders.18 unmodified lines * @return {Server} * @api public */
exports.createServer = function(){ return new HTTPServer(Array.prototype.slice.call(arguments));exports.createServer = function(options){ if ('object' == typeof options) { return new HTTPSServer(options, Array.prototype.slice.call(arguments, 1)); } else { return new HTTPServer(Array.prototype.slice.call(arguments)); }};
/** * Expose `HTTPServer`.21 unmodified linesmodified:lib/http.js+1 added-1 removed
16 unmodified lines17 , url = require('url')18 , utils = connect.utils;19 20 /**21- * Initialize a new `Server` with optional `middleware`.21+ * Initialize a new `HTTPServer` with optional `middleware`.22 *23 * @param {Array} middleware24 * @api public25 */433 unmodified linesadded:lib/https.js+93 added
1+2+/*!3+ * Express - HTTPSServer4+ * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>5+ * MIT Licensed6+ */7+8+/**9+ * Module dependencies.10+ */11+12+var connect = require('connect')13+ , HTTPServer = require('./http')14+ , https = require('https');15+16+/**17+ * Initialize a new `HTTPSServer` with the 18+ * given `options`, and optional `middleware`.19+ *20+ * @param {Object} options21+ * @param {Array} middleware22+ * @api public23+ */24+25+var Server = exports = module.exports = function HTTPSServer(options, middleware){26+ var self = this;27+ this.settings = {};28+ this.redirects = {};29+ this.isCallbacks = {};30+ this.viewHelpers = {};31+ this.dynamicViewHelpers = {};32+ this.errorHandlers = [];33+ connect.HTTPSServer.call(this, options, []);34+35+ // Default "home" to / 36+ this.set('home', '/');37+38+ // Set "env" to NODE_ENV, defaulting to "development"39+ this.set('env', process.env.NODE_ENV || 'development');40+41+ // Expose objects to each other42+ this.use(function(req, res, next){43+ req.query = req.query || {};44+ res.headers = { 'X-Powered-By': 'Express' };45+ req.app = res.app = self;46+ req.res = res;47+ res.req = req;48+ req.next = next;49+ // Assign req.params.get50+ if (req.url.indexOf('?') > 0) {51+ var query = url.parse(req.url).query;52+ req.query = exports.parseQueryString(query);53+ }54+ next();55+ });56+57+ // Apply middleware58+ if (middleware) {59+ middleware.forEach(function(fn){60+ self.use(fn);61+ });62+ }63+64+ // Use router, expose as app.get(), etc65+ var fn = router(function(app){ self.routes = app; });66+ this.__defineGetter__('router', function(){67+ this.__usedRouter = true;68+ return fn;69+ });70+71+ // Default production configuration72+ this.configure('production', function(){73+ this.enable('cache views');74+ });75+};76+77+/**78+ * Inherit from `connect.HTTPSServer`.79+ */80+81+Server.prototype.__proto__ = connect.HTTPSServer.prototype;82+83+/**84+ * Support swappable querystring parsers.85+ */86+87+exports.parseQueryString = queryString.parse;88+89+// mixin HTTPServer methods90+91+Object.keys(HTTPServer.prototype).forEach(function(method){92+ Server.prototype[method] = HTTPServer.prototype[method];93+});