I am working on a legacy project of NodeJS using a very old node version of 0.12.2
Though it is using an expressJS framework version 4.12.4 with body-parser version 1.8.1
Some of the old controllers utilize the native nodeJS method of reading the data stream from the request object to access the body part of the request:
req.on("data", function (data) {
body += data;
});
req.on("end", function () {
console.log(body)
// do something here with body
}
The newer controllers use the bodyParser
to access the data using the following method:
req.body('something')
The body parser is instantiated as:
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.json({limit: '50mb', extended: true}));
This is a very large project (1300+ Api's) running as a production level software.
My question is, is the above a safe practice? Would using bodyParser affect the native request object?
The trouble I am facing is sometimes the legacy controllers time out without returning any response, there are no logs generated, hence unable to debug.