xss-req-sanitizer
is a middleware to sanitize http requests to prevent XSS attacks.
npm install xss-req-sanitizer
var express = require('express')
var bodyParser = require('body-parser')
var xssReqSanitizer = require('xss-req-sanitizer')
var app = express()
app.use(bodyParser.json())
// this should comes before any routes
app.use(xssReqSanitizer())
app.post('/your-route', (req, res) => {
// All the values from,
// req.body, req.params, req.query
// will be sanitized in-place.
})
npm install
npm test