Stable Release in branch 2.x
2.5.11
Released 29 Jun 2012
(13 years ago)
SoftwareExpress
Version2.x
Minimum
Node.js version
Node.js 0.4.1+
Initial release2.0.0
17 Mar 2011
(15 years ago)
Latest release2.5.11
29 Jun 2012
(13 years ago)
End of support (OSS)Jul 2012
(Ended 13 years ago)
Commercial support
(HeroDevs-NES)
Unavailable
Release noteshttps://github.com/expressjs/express/releases/tag/2.5.11
Source codehttps://github.com/expressjs/express/tree/2.5.11
Downloadhttps://github.com/expressjs/express/releases/tag/2.5.11
Express 2.x ReleasesView full list

What Is New in Express 2

CategoryChange
New Featuresres.json() - explicit JSON response; chainable res.status(code); res.locals(obj) and res.local(name,val); app.lookup.VERB() and app.match.VERB() shortcuts; app.VERB() alias; app.param() now accepts multiple callbacks; strict routing setting; case-sensitive routes option; basepath setting for reverse proxies; support for PURGE method; res.contentType literal forms; second-callback support for res.download; options support for res.clearCookie.
ImprovementsView cache defaults to enabled in production; default charset set to utf-8; default cookie path set to "home"; added request, response and app locals; added settings local variable; req.flash now throws if session missing; added req.get(field,param); added req.accepts() extensions; added req.path shortcut; res.helpers alias for res.locals(); res.send(bool) now returns JSON; res.send(undefined) yields 204.
Bug FixesFixed res.redirect HEAD support; fixed res.sendfile bug with spaces in filenames; fixed res.send(undefined) 204 response; fixed view caching collisions across multiple apps; fixed partial lookup precedence; fixed app.all duplicate DELETE handling; fixed app.param callback execution per route middleware; fixed res.header set intention when value undefined; fixed req.is() charset handling; fixed multiple-param callback regression; fixed res.redirect on Windows path joins.
DeprecationsRemoved request and response locals (now only app.locals); removed stream threshold setting.
Breaking ChangesView engine signature changed to engine.compile(str, options) returning a render function; default view cache now enabled in production (affects dev workflow); default charset switched to utf-8; removal of request/response locals may break code that relied on them; view engine .filename option no longer used.

How do I send JSON responses with the new res.json helper?

Use res.json() to send a JSON payload without worrying about content-type or charset.

It automatically sets Content-Type: application/json; charset=utf-8 and stringifies the object.

app.get('/api/user', function(req, res){\n  var user = { id: 7, name: 'Ada' };\n  res.json(user);\n});

Before Express 2 you would write res.send(user) and rely on type detection; now res.json is the explicit, future-proof way.

What are the new routing shortcuts app.lookup, app.match, and app.VERB?

Express 2 adds three helpers that let you query or invoke routes without a full request.

  • app.lookup.VERB(path) returns the route object for a given HTTP verb.
  • app.match.VERB(path) returns true/false if a route matches.
  • app.VERB(path) is a shorthand for app.lookup.VERB(path).

These are handy for feature flags, conditional middleware, or testing route existence.

// check if a GET route exists for /admin\nif (app.match.get('/admin')) {\n  console.log('admin route is defined');\n}\n\n// retrieve the route object for POST /login\nvar postLogin = app.lookup.post('/login');\nconsole.log(postLogin.stack.length); // number of middleware functions

Which view engine changes will break my existing templates?

Express 2 changes the view engine API: engines must now export a compile(str, options) function that returns a render function.

Older engines that exported engine.render(str, options, callback) will throw at runtime.

In practice you need to update custom engines or upgrade third-party ones to the new compile signature.

Additionally, view caching is enabled by default in production, and the default charset is now utf-8, so templates that relied on the previous defaults may render differently.

How do strict routing and case sensitivity affect my route definitions?

Enable app.set('strict routing', true) to make trailing slashes matter and app.set('case sensitive routing', true) to make path case matter.

With strict routing, /users and /users/ are distinct; without it they are treated as the same route.

Case sensitivity means /API will not match a handler defined for /api.

app.set('strict routing', true);\napp.set('case sensitive routing', true);\n\napp.get('/api', function(req, res){ res.send('lowercase'); });\n// GET /API will now 404

This is useful for APIs that need precise URL contracts, but most apps can keep the defaults for flexibility.

Common Questions

Does Express 2 require changes to my view engine implementation?
Yes, view engines must now provide a compile(str, options) function that returns a render function.

How do I enable strict routing?
Call app.set('strict routing', true) before defining your routes.

Can I still use req.flash without a session?
No, req.flash now throws an error if req.session is missing.

What is the new way to send a JSON response?
Use res.json(yourObject) which automatically sets the correct content type and charset.

How do I define a route that handles all HTTP verbs?
Use app.all(path, handler) which registers the handler for every method.

Releases In Branch 2.x

VersionRelease date
2.5.1129 Jun 2012
(13 years ago)
2.5.1015 Jun 2012
(14 years ago)
2.5.902 Apr 2012
(14 years ago)
2.5.402 Jan 2012
(14 years ago)
2.5.330 Dec 2011
(14 years ago)
2.5.210 Dec 2011
(14 years ago)
2.5.117 Nov 2011
(14 years ago)
2.5.024 Oct 2011
(14 years ago)
2.4.705 Oct 2011
(14 years ago)
2.4.519 Aug 2011
(14 years ago)
2.4.405 Aug 2011
(14 years ago)
2.4.314 Jul 2011
(14 years ago)
2.4.106 Jul 2011
(14 years ago)
2.4.206 Jul 2011
(14 years ago)
2.4.028 Jun 2011
(14 years ago)
2.3.1222 Jun 2011
(15 years ago)
2.3.1104 Jun 2011
(15 years ago)
2.3.1027 May 2011
(15 years ago)
2.3.925 May 2011
(15 years ago)
2.3.824 May 2011
(15 years ago)
2.3.723 May 2011
(15 years ago)
2.3.520 May 2011
(15 years ago)
2.3.620 May 2011
(15 years ago)
2.3.408 May 2011
(15 years ago)
2.3.303 May 2011
(15 years ago)
2.3.227 Apr 2011
(15 years ago)
2.3.126 Apr 2011
(15 years ago)
2.3.025 Apr 2011
(15 years ago)
2.2.212 Apr 2011
(15 years ago)
2.2.104 Apr 2011
(15 years ago)
2.2.030 Mar 2011
(15 years ago)
2.1.129 Mar 2011
(15 years ago)
2.1.024 Mar 2011
(15 years ago)
2.0.0rc217 Mar 2011
(15 years ago)
2.0.0rc317 Mar 2011
(15 years ago)
2.0.017 Mar 2011
(15 years ago)
2.0.0rc14 Mar 2011
(15 years ago)
2.0.0beta309 Mar 2011
(15 years ago)
2.0.0beta207 Mar 2011
(15 years ago)