Skip to content
Myr

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

3 files+101 added−3 removed

modified:lib/express.js+7 added-2 removed
modified:lib/http.js+1 added-1 removed
16 unmodified lines
17 , url = require('url')18 , utils = connect.utils;1920/**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 lines
added:lib/https.js+93 added
12/*!3 * Express - HTTPSServer4 * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>5 * MIT Licensed6 */78/**9 * Module dependencies.10 */1112var connect = require('connect')13 , HTTPServer = require('./http')14 , https = require('https');1516/**17 * Initialize a new `HTTPSServer` with the 18 * given `options`, and optional `middleware`.19 *20 * @param {Object} options21 * @param {Array} middleware22 * @api public23 */2425var 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, []);3435 // Default "home" to / 36 this.set('home', '/');3738 // Set "env" to NODE_ENV, defaulting to "development"39 this.set('env', process.env.NODE_ENV || 'development');4041 // 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 });5657 // Apply middleware58 if (middleware) {59 middleware.forEach(function(fn){60 self.use(fn);61 });62 }6364 // 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 });7071 // Default production configuration72 this.configure('production', function(){73 this.enable('cache views');74 });75};7677/**78 * Inherit from `connect.HTTPSServer`.79 */8081Server.prototype.__proto__ = connect.HTTPSServer.prototype;8283/**84 * Support swappable querystring parsers.85 */8687exports.parseQueryString = queryString.parse;8889// mixin HTTPServer methods9091Object.keys(HTTPServer.prototype).forEach(function(method){92 Server.prototype[method] = HTTPServer.prototype[method];93});