Installation
npm i --save express-auto-sanitize
Usage
Import the module with this declaration at the top of the file:
const sanitizer =
Mount the middleware
const options = query: Boolean body: Boolean cookies: Boolean original: Boolean // will keep the original version in req.original sanitizerFunction: Function // use your personnal sanitizing algorithmapp
Note: if you use the body option, make sure you mount the sanitizer between the body-parser/cookie-parser middleware and your routes declaration.
Output
After the middleware has processed the input, the original version will be stored in req.original
and the safe version will replace the dangerous input.
app
License
express-auto-sanitize is MIT licensed.