misc refactoring
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 8480869 · Browse files · 1 file·+22 added−22 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+22 added−22 removed
- other:+22 added−22 removed
Provenance
- Commit
7c15cde- Tree
55b1c69- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
8480869
1 file changed+22 added−22 removed
modified:lib/http.js+22 added-22 removed
126 unmodified lines127 * @api public128 */129 130 Server.prototype.use = function(route, middleware){131- if (typeof route !== 'string') {131+ if ('string' != typeof route) {132 middleware = route, route = '/';133 }134 135 connect.HTTPServer.prototype.use.call(this, route, middleware);136 137- // Mounted an app138- if (middleware instanceof Server) {139- // Home is /:route/:home137+ // mounted an app138+ if (middleware.handle) {139+ // home is /:route/:home140 var app = middleware141 , home = app.set('home');142 if (home === '/') home = '';143 app.set('home', (app.route || '') + home);144 app.parent = this;145- // Mounted hook145+ // mounted hook146 if (app.__mounted) app.__mounted.call(app, this);147 }148 149 return this;4 unmodified lines154 * when this `Server` is passed to `Server#use()`.155 *156 * Examples:157 *158- * var app = express.createServer(),159- * blog = express.createServer();158+ * var app = express.createServer()159+ * , blog = express.createServer();160 *161 * blog.mounted(function(parent){162- * // parent is app163- * // "this" is blog162+ * // parent is app163+ * // "this" is blog164 * });165 *166 * app.use(blog);167 *68 unmodified lines236 *237 * Alternatively the callback may accept the request, response, next, and238 * the value, acting like middlware:239 *240- * app.param('userId', function(req, res, next, id){241- * User.find(id, function(err, user){242- * if (err) {243- * next(err);244- * } else if (user) {245- * req.user = user;246- * next();247- * } else {248- * next(new Error('failed to load user'));249- * }250- * });251- * });240+ * app.param('userId', function(req, res, next, id){241+ * User.find(id, function(err, user){242+ * if (err) {243+ * next(err);244+ * } else if (user) {245+ * req.user = user;246+ * next();247+ * } else {248+ * next(new Error('failed to load user'));249+ * }250+ * });251+ * });252 *253 * Now every time ":userId" is present, the associated user object254 * will be loaded and assigned before the route handler is invoked.255 *138 unmodified lines394 * @api public395 */396 397 Server.prototype.configure = function(env, fn){398- if (typeof env === 'function') {398+ if ('function' == typeof env) {399 fn = env, env = 'all';400 }401 if ('all' == env || env == this.settings.env) {402 fn.call(this);42 unmodified lines