With any luck, all I need is assistance updating deprecated body-parser node module?
I have an AWS instance running the bitnami Parse-Server installed through the AWS marketplace as the backend for an iOS app. The app crashed the other day even though no code changes where made in the iOS code nor the backend javascript running on AWS. The parse server log had the error message below coinciding with when the app crashed, which suggests that the deprecation of body parser is the cause of the issue. I researched this and changed the code in my server.js to what I believed was the new syntax but that didn't fix the problem as I got the error again after updating my server.js
and restarting the server.
error: Forever detected script was killed by signal: SIGKILL
Sat, 24 Aug 2019 03:17:04 GMT body-parser deprecated bodyParser: use individual json/urlencoded middlewares at server.js:117:11
Sat, 24 Aug 2019 03:17:04 GMT body-parser deprecated undefined extended: provide extended option at node_modules/body-parser/index.js:105:29
parse-server running on port 1337
parse-dashboard running on port 4040
WARNING, Unable to connect to 'https://bigdayof.kerrydan.com/parse'. Cloud code and push notifications may be unavailable!
error: Forever detected script was killed by signal: SIGKILL
parse-server running on port 1337
parse-dashboard running on port 4040
WARNING, Unable to connect to 'https://bigdayof.kerrydan.com/parse'. Cloud code and push notifications may be unavailable!
I can supply the entire server.js
but the code is long since it serves a web version of the app as well as the backend for the iOS app. This is the current code at the server.js
that the log calls out at 117 for having the wrong syntax.
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
The log also references node_modules/body-parse/index.js line 105 and the code at that location.
/**
* Create a middleware to parse json and urlencoded bodies.
*
* @param {object} [options]
* @return {function}
* @deprecated
* @public
*/
function bodyParser (options) {
var opts = {}
// exclude type option
if (options) {
for (var prop in options) {
if (prop !== 'type') {
opts[prop] = options[prop]
}
}
}
var _urlencoded = exports.urlencoded(opts)
var _json = exports.json(opts)
return function bodyParser (req, res, next) {
_json(req, res, function (err) {
if (err) return next(err)
_urlencoded(req, res, next)
})
}
}
I suspect that I had to do more than update the server.js and restart but I am not very experienced at backend programming for my iOS apps. Perhaps I need to completely re-install the body-parse package and that will update the node_module? Or maybe there are additional things I needed to change in the server.js?
Any advice or help would be greatly appreciated. Feel free to ask for any additional detail and I will add to this post with any details that I may not have known to include here.
Thank You.