Skip to content
Myr

refactoring boot logic

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 371b381 · Browse files · 1 file+36 added−25 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+36 added−25 removed

  • other:+36 added−25 removed

1 file+36 added−25 removed

modified:lib/application.js+36 added-25 removed
29 unmodified lines
3031/**32 * Initialize the server.33 *34 * @param {Array} middleware34 * - setup default configuration35 * - setup default middleware36 * - setup route reflection methods37 *38 * @api private39 */4038app.init = function(middleware){41app.init = function(){42 var self = this;43 this.cache = {};44 this.settings = {};45 this.engines = {};46 this.redirects = {};47 this.isCallbacks = {};48 this.defaultConfiguration();4950 // route manipulation methods51 methods.forEach(function(method){52 self.lookup[method] = function(path){53 return self.routes.lookup(method, path);54 };5556 self.match[method] = function(path){57 return self.routes.match(method, path);58 };5960 self.remove[method] = function(path){61 return self.routes.lookup(method, path).remove();62 };63 });6465 // del -> delete66 self.lookup.del = self.lookup.delete;67 self.match.del = self.match.delete;68 self.remove.del = self.remove.delete;69};7071/**72 * Initialize application configuration.73 *74 * @api private75 */7677app.defaultConfiguration = function(){78 var self = this;7980 // default settings81 this.set('home', '/');82 this.set('env', process.env.NODE_ENV || 'development');83
46 unmodified lines
130131 next();132 });133100 // apply middleware101 if (middleware) middleware.forEach(self.use.bind(self));102134 // router135 this.routes = new Router(this);136 this.__defineGetter__('router', function(){137 this.__usedRouter = true;
6 unmodified lines
144 // default production configuration145 this.configure('production', function(){146 this.enable('view cache');147 });117118 // route manipulation methods119 methods.forEach(function(method){120 self.lookup[method] = function(path){121 return self.routes.lookup(method, path);122 };123124 self.match[method] = function(path){125 return self.routes.match(method, path);126 };127128 self.remove[method] = function(path){129 return self.routes.lookup(method, path).remove();130 };131 });132133 // del -> delete134 self.lookup.del = self.lookup.delete;135 self.match.del = self.match.delete;136 self.remove.del = self.remove.delete;148};149150/**151 * Remove routes matching the given `path`.
465 unmodified lines