January 13, 2021
I was starting a node express project today. Simple things I learnt today.
It is an express middleware. According to its website,
Note As req.body’s shape is based on user-controlled input, all properties and values in this object are untrusted and should be validated before trusting. For example, req.body.foo.toString() may fail in multiple ways, for example the foo property may not be there or may not be a string, and toString may not be a function and instead a string or other user input.
To sanitize the data in your request, better to use this.
require("crypto").randomBytes(16).toString("hex")
The next best thing is that crypo is inbuilt into node. Quick and easy.