Fork me on GitHub

High performance, high class web development for Node.js

Express

migrate

Express 1.x to 2.x Migration

HTTPS

Creating an HTTPS server is simply, simply pass the TLS options to express.createServer():

 var app = express.createServer({
     key: ...
   , cert: ...
 });

 app.listen(443);

req.header() Referrer

Previously if anyone was doing something similar to:

 req.headers.referrer || req.headers.referer
 req.header('Referrer') || req.header('Referer')

With the new special-case we may now simply use Referrer which will return either if defined:

 req.header('Referrer')

res.local(name, val)

Previously all local variables had to be passed to res.render(), or either app.helpers() or app.dynamicHelpers(), now we may do this at the request-level progressively. The res.local() method accepts a name and val, however the locals passed to res.render() will take precedence.

For example we may utilize this feature to create locals in middleware:

 function loadUser(req, res, next) {
   User.get(req.params.id, function(err, user){
     res.local('user', user);
     next();
   });
 }

 app.get('/user/:id', loadUser, function(req, res){
   res.render('user');
 });