With the start of 2017, it’s time to adapt these changes ExpressJS 5.0 is in alpha release stage but I believe we’ll be adding it as a dependency in our files in matter of no time. This article gives some tips regarding the way we are writing code using this framework and how we should adapt the new changes even if we are using ExpressJS . package.json version 4.0 I’ll start with most common thing such as . response Express 5 no longer supports the signature , instead we should adapt using this method in this form: res.send res.status(statusCode).send(); We have to set the status code before sending the response object. This new version of is basically a chain of two methods: & . res.send res.status res.send With that mind, ExpressJS 5 deprecates method where is the number representing the HTTP response header status code. To send just the statusCode, that is, without sending the response object, we can use method. res.send(statusCode) statusCode res.sendStatus(statusCode) In similar manner, other methods that have been changed are: res.json() --> res.status().json()res.jsonp() --> res.status.jsonp() Another notable method that is going to be deprecated in next version of ExpressJS is . Instead, we must adapt its new form, the camelCase one: which is already been supported by the ExpressJS versions later than . It comes with optional parameters that you can check them res.sendfile() res.sendFile() 4.8.x here . Whether you are planning to use the alpha release of Express 5.0 or still going on with the latest versions of Express 4.0, I would suggest to start adapting these methods immediately. The full list of changes or the official Express Migration Guide is to be found here . 💚 Thank you for reading. If you find this post useful, please hit the readers_. If you’d like to talk about it more, ping me on_ button so this story can reach out to more Twitter | Goodreads | Book Blog | Website | My articles on Hackernoon.com
Share Your Thoughts