Skip to content
Myr

application.js

This file

Path

lib/application.js

606 lines · 12.6 KiB · JavaScript

Last changed by

Added app.listen() as a shortcut for http.createServer(app).listen()Tj Holowaychukbefore adoption9082e74

History of this file

Take it

The walk stopped after 200 commits: lines older than e904132 point at it.

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 1–14why, one step back
1
2/*!3 * Express - proto4 * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>5 * MIT Licensed6 */78/**9 * Module dependencies.10 */1112var connect = require('connect')13 , Router = require('./router')14 , methods = Router.methods.concat('del', 'all')

new ViewTj Holowaychukbefore adoptione1da383

line 15why, one step back
15 , View = require('./view')

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 16–18why, one step back
16 , url = require('url')
17 , utils = connect.utils18 , path = require('path')

Added app.listen() as a shortcut for http.createServer(app).listen()Tj Holowaychukbefore adoption9082e74

line 19why, one step back
19 , http = require('http')

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 20–32why, one step back
20 , join = path.join
21 , fs = require('fs')22 , qs = require('qs');2324/**25 * Expose `HTTPServer`.26 */2728var app = exports = module.exports = {};2930/**31 * Initialize the server.32 *

refactoring boot logicTj Holowaychukbefore adoption8848004

lines 33–36why, one step back
33 * - setup default configuration
34 * - setup default middleware35 * - setup route reflection methods36 *

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 37–39why, one step back
37 * @api private
38 */39

refactoring boot logicTj Holowaychukbefore adoption8848004

line 40why, one step back
40app.init = function(){

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

line 41why, one step back
41 var self = this;

app.lookup()Tj Holowaychukbefore adoption76b7d69

line 42why, one step back
42 this.cache = {};

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 43–46why, one step back
43 this.settings = {};
44 this.engines = {};45 this.redirects = {};46 this.isCallbacks = {};

app.locals.use(fn)Tj Holowaychukbefore adoption0f6ad43

line 47why, one step back
47 this.viewCallbacks = [];

refactoring boot logicTj Holowaychukbefore adoption8848004

line 48why, one step back
48 this.defaultConfiguration();

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

line 49why, one step back
49

miscTj Holowaychukbefore adoptiond4b08e9

line 50why, one step back
50 // route reflection methods

refactoring boot logicTj Holowaychukbefore adoption8848004

lines 51–52why, one step back
51 methods.forEach(function(method){
52 self.lookup[method] = function(path){

Added `app.routes`, replacing `app.routes.all()`. Closes #811Tj Holowaychukbefore adoption62257bc

line 53why, one step back
53 return self._router.lookup(method, path);

refactoring boot logicTj Holowaychukbefore adoption8848004

lines 54–56why, one step back
54 };
5556 self.match[method] = function(path){

Added `app.routes`, replacing `app.routes.all()`. Closes #811Tj Holowaychukbefore adoption62257bc

line 57why, one step back
57 return self._router.match(method, path);

refactoring boot logicTj Holowaychukbefore adoption8848004

lines 58–60why, one step back
58 };
5960 self.remove[method] = function(path){

Added `app.routes`, replacing `app.routes.all()`. Closes #811Tj Holowaychukbefore adoption62257bc

line 61why, one step back
61 return self._router.lookup(method, path).remove();

refactoring boot logicTj Holowaychukbefore adoption8848004

lines 62–79why, one step back
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;79

req.query is always presentTj Holowaychukbefore adoptiond1ce4c9

line 80why, one step back
80 // default settings

Fixed res.clearCookie(), default path to "root" settingTj Holowaychukbefore adoption0f2f3d4

line 81why, one step back
81 this.set('root', '/');

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

line 82why, one step back
82 this.set('env', process.env.NODE_ENV || 'development');

req.query is always presentTj Holowaychukbefore adoptiond1ce4c9

lines 83–84why, one step back
83
84 // always parse req.query

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 85–87why, one step back
85 this.use(connect.query());
8687 this.locals = function(obj){

misc refactoringTj Holowaychukbefore adoption4ed92d5

line 88why, one step back
88 for (var key in obj) self.locals[key] = obj[key];

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

line 89why, one step back
89 return self;

app.locals.use(fn)Tj Holowaychukbefore adoption0f6ad43

lines 90–92why, one step back
90 };
9192 this.locals.use = function(fn){

added sync signature for app.locals.use()Tj Holowaychukbefore adoption965e1d6

lines 93–100why, one step back
93 if (3 == fn.length) {
94 self.viewCallbacks.push(fn);95 } else {96 self.viewCallbacks.push(function(req, res, done){97 fn(req, res);98 done();99 });100 }

app.locals.use(fn)Tj Holowaychukbefore adoption0f6ad43

line 101why, one step back
101 return this;

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 102–111why, one step back
102 };
103104 // expose objects to each other105 this.use(function(req, res, next){106 var charset;107 res.setHeader('X-Powered-By', 'Express');108 req.app = res.app = self;109 req.res = res;110 res.req = req;111 req.next = next;

no longer manipulate the req/res protos directlyTj Holowaychukbefore adoptiond249868

line 112why, one step back
112

make sure req/res protos are app-specificTj Holowaychukbefore adoptione27b224

lines 113–114why, one step back
113 req.__proto__ = self.request;
114 res.__proto__ = self.response;

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 115–116why, one step back
115
116 res.locals = function(obj){

misc refactoringTj Holowaychukbefore adoption4ed92d5

line 117why, one step back
117 for (var key in obj) res.locals[key] = obj[key];

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 118–124why, one step back
118 return res;
119 };120121 next();122 });123124 // router

Added `app.routes`, replacing `app.routes.all()`. Closes #811Tj Holowaychukbefore adoption62257bc

lines 125–126why, one step back
125 this._router = new Router(this);
126 this.routes = this._router.routes;

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

line 127why, one step back
127 this.__defineGetter__('router', function(){

fixed auto use(app.router)Tj Holowaychukbefore adoption92c5284

line 128why, one step back
128 this._usedRouter = true;

Added `app.routes`, replacing `app.routes.all()`. Closes #811Tj Holowaychukbefore adoption62257bc

line 129why, one step back
129 return self._router.middleware;

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 130–149why, one step back
130 });
131132 // default locals133 this.locals.settings = this.settings;134135 // default production configuration136 this.configure('production', function(){137 this.enable('view cache');138 });139};140141/**142 * Remove routes matching the given `path`.143 *144 * @param {Route} path145 * @return {Boolean}146 * @api public147 */148149app.remove = function(path){

Added `app.routes`, replacing `app.routes.all()`. Closes #811Tj Holowaychukbefore adoption62257bc

line 150why, one step back
150 return this._router.lookup('all', path).remove();

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 151–162why, one step back
151};
152153/**154 * Lookup routes defined with a path155 * equivalent to `path`.156 *157 * @param {Stirng} path158 * @return {Array}159 * @api public160 */161162app.lookup = function(path){

Added `app.routes`, replacing `app.routes.all()`. Closes #811Tj Holowaychukbefore adoption62257bc

line 163why, one step back
163 return this._router.lookup('all', path);

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 164–174why, one step back
164};
165166/**167 * Lookup routes matching the given `url`.168 *169 * @param {Stirng} url170 * @return {Array}171 * @api public172 */173174app.match = function(url){

Added `app.routes`, replacing `app.routes.all()`. Closes #811Tj Holowaychukbefore adoption62257bc

line 175why, one step back
175 return this._router.match('all', url);

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 176–178why, one step back
176};
177178/**

docsTj Holowaychukbefore adoption2e22887

line 179why, one step back
179 * Proxy `connect#use()` to apply settings to

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 180–183why, one step back
180 * mounted applications.
181 *182 * @param {String|Function|Server} route183 * @param {Function|Server} middleware

Added app.listen() as a shortcut for http.createServer(app).listen()Tj Holowaychukbefore adoption9082e74

line 184why, one step back
184 * @return {app} for chaining

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 185–214why, one step back
185 * @api public
186 */187188app.use = function(route, middleware){189 var app, home, handle;190191 if ('string' != typeof route) {192 middleware = route, route = '/';193 }194195 // express app196 if (middleware.handle && middleware.set) app = middleware;197198 // restore .app property on req and res199 if (app) {200 app.route = route;201 middleware = function(req, res, next) {202 var orig = req.app;203 app.handle(req, res, function(err){204 req.app = res.app = orig;205 next(err);206 });207 };208 }209210 connect.proto.use.call(this, route, middleware);211212 // mounted an app, invoke the hook213 // and adjust some settings214 if (app) {

tweak res.redirect() mount route logicTj Holowaychukbefore adoption43d9f6e

lines 215–218why, one step back
215 var root = this.get('root') || this.route;
216 if ('/' == root) root = '';217 root = root + (app.get('root') || app.route);218 app.set('root', root);

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 219–242why, one step back
219 app.parent = this;
220 if (app.__mounted) app.__mounted.call(app, this);221 }222223 return this;224};225226/**227 * Assign a callback `fn` which is called228 * when this `Server` is passed to `Server#use()`.229 *230 * Examples:231 *232 * var app = express.createServer()233 * , blog = express.createServer();234 *235 * blog.mounted(function(parent){236 * // parent is app237 * // "this" is blog238 * });239 *240 * app.use(blog);241 *242 * @param {Function} fn

Added app.listen() as a shortcut for http.createServer(app).listen()Tj Holowaychukbefore adoption9082e74

line 243why, one step back
243 * @return {app} for chaining

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 244–256why, one step back
244 * @api public
245 */246247app.mounted = function(fn){248 this.__mounted = fn;249 return this;250};251252/**253 * Register the given template engine callback `fn`254 * as `ext`. For example we may wish to map ".html"255 * files to ejs rather than using the ".ejs" extension.256 *

Added app.engine() testsTj Holowaychukbefore adoption66f8ca5

line 257why, one step back
257 * app.engine('.html', require('ejs').render);

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 258–260why, one step back
258 *
259 * or260 *

Added app.engine() testsTj Holowaychukbefore adoption66f8ca5

line 261why, one step back
261 * app.engine('html', require('ejs').render);

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 262–264why, one step back
262 *
263 * @param {String} ext264 * @param {Function} fn

Added app.listen() as a shortcut for http.createServer(app).listen()Tj Holowaychukbefore adoption9082e74

line 265why, one step back
265 * @return {app} for chaining

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 266–268why, one step back
266 * @api public
267 */268

Added app.engine() testsTj Holowaychukbefore adoption66f8ca5

line 269why, one step back
269app.engine = function(ext, fn){

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 270–329why, one step back
270 if ('.' != ext[0]) ext = '.' + ext;
271 this.engines[ext] = fn;272 return this;273};274275/**276 * Map the given param placeholder `name`(s) to the given callback(s).277 *278 * Param mapping is used to provide pre-conditions to routes279 * which us normalized placeholders. This callback has the same280 * signature as regular middleware, for example below when ":userId"281 * is used this function will be invoked in an attempt to load the user.282 *283 * app.param('userId', function(req, res, next, id){284 * User.find(id, function(err, user){285 * if (err) {286 * next(err);287 * } else if (user) {288 * req.user = user;289 * next();290 * } else {291 * next(new Error('failed to load user'));292 * }293 * });294 * });295 *296 * Passing a single function allows you to map logic297 * to the values passed to `app.param()`, for example298 * this is useful to provide coercion support in a concise manner.299 *300 * The following example maps regular expressions to param values301 * ensuring that they match, otherwise passing control to the next302 * route:303 *304 * app.param(function(name, regexp){305 * if (regexp instanceof RegExp) {306 * return function(req, res, next, val){307 * var captures;308 * if (captures = regexp.exec(String(val))) {309 * req.params[name] = captures;310 * next();311 * } else {312 * next('route');313 * }314 * }315 * }316 * });317 *318 * We can now use it as shown below, where "/commit/:commit" expects319 * that the value for ":commit" is at 5 or more digits. The capture320 * groups are then available as `req.params.commit` as we defined321 * in the function above.322 *323 * app.param('commit', /^\d{5,}$/);324 *325 * For more of this useful functionality take a look326 * at [express-params](http://github.com/visionmedia/express-params).327 *328 * @param {String|Array|Function} name329 * @param {Function} fn

Added app.listen() as a shortcut for http.createServer(app).listen()Tj Holowaychukbefore adoption9082e74

line 330why, one step back
330 * @return {app} for chaining

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 331–346why, one step back
331 * @api public
332 */333334app.param = function(name, fn){335 var self = this336 , fns = [].slice.call(arguments, 1);337338 // array339 if (Array.isArray(name)) {340 name.forEach(function(name){341 fns.forEach(function(fn){342 self.param(name, fn);343 });344 });345 // param logic346 } else if ('function' == typeof name) {

Added `app.routes`, replacing `app.routes.all()`. Closes #811Tj Holowaychukbefore adoption62257bc

line 347why, one step back
347 this._router.param(name);

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 348–351why, one step back
348 // single
349 } else {350 if (':' == name[0]) name = name.substr(1);351 fns.forEach(function(fn){

Added `app.routes`, replacing `app.routes.all()`. Closes #811Tj Holowaychukbefore adoption62257bc

line 352why, one step back
352 self._router.param(name, fn);

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 353–363why, one step back
353 });
354 }355356 return this;357};358359/**360 * Register the given callback `fn` for the given `type`.361 *362 * @param {String} type363 * @param {Function} fn

Added app.listen() as a shortcut for http.createServer(app).listen()Tj Holowaychukbefore adoption9082e74

line 364why, one step back
364 * @return {app} for chaining

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 365–424why, one step back
365 * @api public
366 */367368app.is = function(type, fn){369 if (!fn) return this.isCallbacks[type];370 this.isCallbacks[type] = fn;371 return this;372};373374/**375 * Assign `setting` to `val`, or return `setting`'s value.376 * Mounted servers inherit their parent server's settings.377 *378 * @param {String} setting379 * @param {String} val380 * @return {Server|Mixed} for chaining, or the setting value381 * @api public382 */383384app.set = function(setting, val){385 if (val === undefined) {386 if (this.settings.hasOwnProperty(setting)) {387 return this.settings[setting];388 } else if (this.parent) {389 return this.parent.set(setting);390 }391 } else {392 this.settings[setting] = val;393 return this;394 }395};396397/**398 * Check if `setting` is enabled.399 *400 * @param {String} setting401 * @return {Boolean}402 * @api public403 */404405app.enabled = function(setting){406 return !!this.set(setting);407};408409/**410 * Check if `setting` is disabled.411 *412 * @param {String} setting413 * @return {Boolean}414 * @api public415 */416417app.disabled = function(setting){418 return !this.set(setting);419};420421/**422 * Enable `setting`.423 *424 * @param {String} setting

Added app.listen() as a shortcut for http.createServer(app).listen()Tj Holowaychukbefore adoption9082e74

line 425why, one step back
425 * @return {app} for chaining

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 426–436why, one step back
426 * @api public
427 */428429app.enable = function(setting){430 return this.set(setting, true);431};432433/**434 * Disable `setting`.435 *436 * @param {String} setting

Added app.listen() as a shortcut for http.createServer(app).listen()Tj Holowaychukbefore adoption9082e74

line 437why, one step back
437 * @return {app} for chaining

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 438–449why, one step back
438 * @api public
439 */440441app.disable = function(setting){442 return this.set(setting, false);443};444445/**446 * Redirect `key` to `url`.447 *448 * @param {String} key449 * @param {String} url

Added app.listen() as a shortcut for http.createServer(app).listen()Tj Holowaychukbefore adoption9082e74

line 450why, one step back
450 * @return {app} for chaining

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 451–480why, one step back
451 * @api public
452 */453454app.redirect = function(key, url){455 this.redirects[key] = url;456 return this;457};458459/**460 * Configure callback for zero or more envs,461 * when no env is specified that callback will462 * be invoked for all environments. Any combination463 * can be used multiple times, in any order desired.464 *465 * Examples:466 *467 * app.configure(function(){468 * // executed for all envs469 * });470 *471 * app.configure('stage', function(){472 * // executed staging env473 * });474 *475 * app.configure('stage', 'production', function(){476 * // executed for stage and production477 * });478 *479 * @param {String} env...480 * @param {Function} fn

Added app.listen() as a shortcut for http.createServer(app).listen()Tj Holowaychukbefore adoption9082e74

line 481why, one step back
481 * @return {app} for chaining

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 482–486why, one step back
482 * @api public
483 */484485app.configure = function(env, fn){486 var envs = 'all'

Removed toArray() utilTj Holowaychukbefore adoption7a7d77e

line 487why, one step back
487 , args = [].slice.call(arguments);

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 488–494why, one step back
488 fn = args.pop();
489 if (args.length) envs = args;490 if ('all' == envs || ~envs.indexOf(this.settings.env)) fn.call(this);491 return this;492};493494/**

Added app.listen() as a shortcut for http.createServer(app).listen()Tj Holowaychukbefore adoption9082e74

lines 495–509why, one step back
495 * Listen for connections.
496 *497 * This method takes the same arguments498 * as node's `http.Server#listen()`. 499 *500 * @return {http.Server}501 * @api public502 */503504app.listen = function(){505 var server = http.createServer(this);506 return server.listen.apply(server, arguments);507};508509/**

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 510–514why, one step back
510 * Delegate `.VERB(...)` calls to `.route(VERB, ...)`.
511 */512513methods.forEach(function(method){514 app[method] = function(path){

Added `app.get(setting)`. Closes #842Tj Holowaychukbefore adoptione0bd0d6

line 515why, one step back
515 if ('get' == method && 1 == arguments.length) return this.set(path);

Removed toArray() utilTj Holowaychukbefore adoption7a7d77e

line 516why, one step back
516 var args = [method].concat([].slice.call(arguments));

fixed auto use(app.router)Tj Holowaychukbefore adoption92c5284

line 517why, one step back
517 if (!this._usedRouter) this.use(this.router);

Added `app.routes`, replacing `app.routes.all()`. Closes #811Tj Holowaychukbefore adoption62257bc

line 518why, one step back
518 return this._router._route.apply(this._router, args);

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 519–527why, one step back
519 }
520});521522/**523 * Special-cased "all" method, applying the given route `path`,524 * middleware, and callback to _every_ HTTP method.525 *526 * @param {String} path527 * @param {Function} ...

Added app.listen() as a shortcut for http.createServer(app).listen()Tj Holowaychukbefore adoption9082e74

line 528why, one step back
528 * @return {app} for chaining

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 529–545why, one step back
529 * @api public
530 */531532app.all = function(path){533 var args = arguments;534 methods.forEach(function(method){535 if ('all' == method) return;536 app[method].apply(this, args);537 }, this);538 return this;539};540541// del -> delete alias542543app.del = app.delete;544545/**

new ViewTj Holowaychukbefore adoptione1da383

line 546why, one step back
546 * Render the given view `name` name with `options`

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 547–549why, one step back
547 * and a callback accepting an error and the
548 * rendered template string.549 *

new ViewTj Holowaychukbefore adoptione1da383

line 550why, one step back
550 * @param {String} name

misc refactoringTj Holowaychukbefore adoption294bc8c

line 551why, one step back
551 * @param {String|Function} options or fn

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 552–555why, one step back
552 * @param {Function} fn
553 * @api public554 */555

new ViewTj Holowaychukbefore adoptione1da383

line 556why, one step back
556app.render = function(name, options, fn){

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

line 557why, one step back
557 var self = this

merging res.localsTj Holowaychukbefore adoption98e2c05

line 558why, one step back
558 , opts = {}

re-implemented "view cache"Tj Holowaychukbefore adoption8a38211

line 559why, one step back
559 , cache = this.cache

new ViewTj Holowaychukbefore adoptione1da383

lines 560–561why, one step back
560 , engines = this.engines
561 , view;

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 562–563why, one step back
562
563 // support callback function as second arg

misc refactoringTj Holowaychukbefore adoption294bc8c

lines 564–565why, one step back
564 if ('function' == typeof options) {
565 fn = options, options = {};

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 566–568why, one step back
566 }
567568 // merge app.locals

merging res.localsTj Holowaychukbefore adoption98e2c05

line 569why, one step back
569 utils.merge(opts, this.locals);

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

line 570why, one step back
570

merging res.localsTj Holowaychukbefore adoption98e2c05

lines 571–579why, one step back
571 // merge options.locals
572 if (options.locals) {573 utils.merge(opts, options.locals);574 delete opts.locals;575 }576577 // merge options578 utils.merge(opts, options);579

new ViewTj Holowaychukbefore adoptione1da383

lines 580–583why, one step back
580 // set .cache unless explicitly provided
581 opts.cache = null == opts.cache582 ? this.enabled('view cache')583 : opts.cache;

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

line 584why, one step back
584

new ViewTj Holowaychukbefore adoptione1da383

lines 585–586why, one step back
585 // primed cache
586 if (opts.cache) view = cache[name];

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

line 587why, one step back
587

new ViewTj Holowaychukbefore adoptione1da383

lines 588–590why, one step back
588 // view
589 if (!view) {590 view = new View(name, {

Fixed app.render() absolute path supportTj Holowaychukbefore adoptionb9dee73

lines 591–592why, one step back
591 defaultEngine: this.get('view engine')
592 , root: this.get('views') || process.cwd() + '/views'

new ViewTj Holowaychukbefore adoptione1da383

lines 593–594why, one step back
593 , engines: engines
594 });

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

line 595why, one step back
595

new ViewTj Holowaychukbefore adoptione1da383

lines 596–599why, one step back
596 // prime the cache
597 if (opts.cache) cache[name] = view;598 }599

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 600–601why, one step back
600 // render
601 try {

new ViewTj Holowaychukbefore adoptione1da383

line 602why, one step back
602 view.render(opts, fn);

use app.engines instead of app.cacheTj Holowaychukbefore adoptione904132

lines 603–606why, one step back
603 } catch (err) {
604 fn(err);605 }606};