app.disable()

app.disable(name) Sets the Boolean setting name to false, where name is one of the properties from the app settings table. Calling app.set('foo', false) for a Boolean property is the same as calling app.disable('foo'). For example: app.disable('trust proxy'); app.get('trust proxy'); // => false

app.put()

app.put(path, callback [, callback ...]) Routes HTTP PUT requests to the specified path with the specified callback functions. For more information, see the routing guide. You can provide multiple callback functions that behave just like middleware, except that these callbacks can invoke next('route') to bypass the remaining route callback(s). You can use this mechanism to impose pre-conditions on a route, then pass control to subsequent routes if there’s no reason to proceed with the current r

req.method

req.method Contains a string corresponding to the HTTP method of the request: GET, POST, PUT, and so on.

req.params

req.params This property is an object containing properties mapped to the named route “parameters”. For example, if you have the route /user/:name, then the “name” property is available as req.params.name. This object defaults to {}. // GET /user/tj req.params.name // => "tj" When you use a regular expression for the route definition, capture groups are provided in the array using req.params[n], where n is the nth capture group. This rule is applied to unnamed wild card matches with string

req.app

req.app This property holds a reference to the instance of the Express application that is using the middleware. If you follow the pattern in which you create a module that just exports a middleware function and require() it in your main file, then the middleware can access the Express instance via req.app For example: //index.js app.get('/viewdirectory', require('./mymiddleware.js')) //mymiddleware.js module.exports = function (req, res) { res.send('The views directory is ' + req.app.get('v

app.path()

app.path() Returns the canonical path of the app, a string. var app = express() , blog = express() , blogAdmin = express(); app.use('/blog', blog); blog.use('/admin', blogAdmin); console.log(app.path()); // '' console.log(blog.path()); // '/blog' console.log(blogAdmin.path()); // '/blog/admin' The behavior of this method can become very complicated in complex cases of mounted apps: it is usually better to use req.baseUrl to get the canonical path of the app.

res.attachment()

res.attachment([filename]) Sets the HTTP response Content-Disposition header field to “attachment”. If a filename is given, then it sets the Content-Type based on the extension name via res.type(), and sets the Content-Disposition “filename=” parameter. res.attachment(); // Content-Disposition: attachment res.attachment('path/to/logo.png'); // Content-Disposition: attachment; filename="logo.png" // Content-Type: image/png

res.vary()

res.vary(field) Adds the field to the Vary response header, if it is not there already. res.vary('User-Agent').render('docs');

Moving to Express 4

Overview Express 4 is a breaking change from Express 3, so. That means an existing Express 3 app will not work if you update the Express version in its dependencies. This article covers: Changes in Express 4. An example of migrating an Express 3 app to Express 4. Upgrading to the Express 4 app generator. Changes in Express 4 There are several significant changes in Express 4: Changes to Express core and middleware system. The dependencies on Connect and built-in middleware were removed, so

req.xhr

req.xhr A Boolean property that is true if the request’s X-Requested-With header field is “XMLHttpRequest”, indicating that the request was issued by a client library such as jQuery. req.xhr // => true