ExpressJS 5.0: What’s New

Installing ExpressJS 5.0

To install the latest alpha and to preview Express 5, enter the following command in your application root directory:

npm install express@5.0.0-alpha.8 — save

ExpressJS 5.0 Changelog

Here is the list of changes (as of the alpha 2 release) that will affect you as an Express user.

List of Deprecated Things Removed:

  1. app.del
app.del(‘/res’, (req, res) => res.send(‘deleted’));
//4: express deprecated app.del: Use app.delete instead
//5: TypeError: app.del is not a function
// Old
app.get(‘/users/:name’, (req, res) => {
res.send(User.find(req.param(‘name’)));
});

//4: express deprecated req.param(name): Use req.params, req.body, or req.query instead

//5: TypeError: req.param is not a function
// New
app.get(‘/user/:name’, (req, res) => {
res.send(User.find(req.params.name));
});
// The req.acceptsCharset() changes to req.acceptsCharsets) array
req.acceptsCharsets()
// The req.acceptsEncoding() changes to req.acceptsEncodings() array
req.acceptsEncodings()
// The req.acceptsLanguage() changes to req.acceptsLanguages() array
req.acceptsLanguages()
// The res.json(status, obj) changes to res.status(status).json(obj)
// The res.jsonp(status, obj) changes to res.status(status).jsonp(obj)
The res.send(obj, status) changes to res.status(status).send(obj)
// The res.send(status) changes to res.sendStatus(statusCode)
res.sendStatus(statusCode)
// res.sendfile() is change to a Camel-Case res.sendFile()
res.sendFile()

Improvements

The following are the list of improvements that ExpressJS 5.0 is coming with:

  1. Add support for Promises in all handlers
  2. Bring back app.router which is just generally useful for directly calling the router.
  3. Make sure 3.x-style app.use(app.router) does not explode.
  4. Fix views to resolve paths async.
  5. Make query parser option default to ‘simple’.
  6. Make req.host actually, return the host.
  7. Make req.query a getter instead of added by middleware.
  8. Make res.render always async callback to hide sync view engines.
  9. Make res.sendFile use the “ETag” application setting.
  10. Make res.status throw on invalid argument type.
  11. Make express.static use the “ETag” application setting.
  12. New path matching syntax.
  13. Provide separate locals and options to view the engine.
  14. Remove Express 3.x middleware error stubs.
  15. Support Node.js core HTTP/2 implementation.
  16. Support non-core HTTP prototypes (e.g. http2, shot and others).
  17. Use mime-types instead of mime.
  18. Use path-is-absolute module for absolute path detection

Conclusion

Express 5 is still in alpha, so there are bound to change. Take a look at this [pull request](https://github.com/expressjs/express/pull/2237) if you want to see an updated list of changes for the release.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Solomon Eseme

Solomon Eseme

523 Followers

A Software Developer who’s geared towards building high performing and innovative products following best practices. Blog @ https://masteringbackend.com