ExpressJS 5.0: What’s New

Solomon Eseme
3 min readOct 11, 2017

Express is a minimal and flexible Node.js web application framework that provides robust web and mobile application features.

ExpressJS is one of the best frameworks for Node.js, and it is also a member of the MEAN Stack family, making it very popular.

There are many version of ExpressJS since the first released from version 0.0.1, which started the project in 2010–01–03 to 4.16.2 in 2017–10–09
Express 5.0 is still in the alpha release stage, but here is a preview of the changes that will be in the release.

Express 5 is not very different from Express 4: The changes to the API are not as significant as from 3.0 to 4.0. Although the basic API remains the same, there are still breaking changes; in other words, an existing Express 4 program might not work if you update it to use Express 5.

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

After installing the newest version, you can then run your automated test to see failures and fix the errors according to the updates listed below. After addressing test failures, run your app to see what errors occur. If your app uses any of the deprecated methods, Express will show the errors right away.

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

2. app.param(name)

// 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));
});

3. req.acceptsCharset

// The req.acceptsCharset() changes to req.acceptsCharsets) array
req.acceptsCharsets()

4. req.acceptsEncoding

// The req.acceptsEncoding() changes to req.acceptsEncodings() array
req.acceptsEncodings()

5. req.acceptsLanguage

// The req.acceptsLanguage() changes to req.acceptsLanguages() array
req.acceptsLanguages()

6. res.json(status, obj)

// The res.json(status, obj) changes to res.status(status).json(obj)

7. res.jsonp(status, obj)

// The res.jsonp(status, obj) changes to res.status(status).jsonp(obj)

8. res.send(body, status)

The res.send(obj, status) changes to res.status(status).send(obj)

9. res.send(status)

// The res.send(status) changes to res.sendStatus(statusCode)
res.sendStatus(statusCode)

10. res.sendfile()

// 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.

Thank you for reading my article.

Here at my blog or medium, I regularly write about backend development, digital marketing and content management system. To read my future posts, join my publication or click ‘Follow’ Also, feel free to connect with me via Twitter, Facebook, Instagram.

If you are interested in backend development (or you’re an internet enthusiast) both (Mobile | Web | Desktop) videos, subscribe to my Youtube channel, we will be posting a collection of help full tutorials and guides like this one for artisans.

If you enjoy this post, make sure to let us know and share it with your friends and subscribe to my growing channel.

Sharing is caring.

--

--

Solomon Eseme
Solomon Eseme

Written by Solomon Eseme

A Software Engineer who’s geared towards building high performing and innovative products. I help you become a great Backend Engineer @ masteringbackend.com

No responses yet