The solution is provided in the very article you linked to.
Avoid bodyParser and explicitly use the middleware that you need
If you want to parse json in your endpoint, use express.json()
middleware. If you want json and urlencoded endpoint, use [express.json(), express.urlencoded()]
for your middleware.
If you want users to upload files to your endpoint, you could use express.multipart()
and be sure to clean up all the temp files that are created. This would still stuffer [sic] from problem #3 previously mentioned.
Note however that in Express 4, these middlewares are no longer packaged with Express. They are now available via the body-parser
package, with json
and urlencoded
properties. They recommend some other packages for multipart uploads.