1.0.4 • Published 3 years ago

express-route-sanitizer-middleware v1.0.4

Weekly downloads
2
License
ISC
Repository
github
Last release
3 years ago

Express Route Sanitizer Middleware

This middleware will enable sanitizing requests on a route-scope, with minimum addition of code.

The main goal is to eliminate attemps to exploit XSS flaws on our express web server in order to keep sensitive back-end services working as usual.

The package uses minimal dependencies in order to simulate the browser's DOM and sanitize all requested data. Packages: DOMPurify, JSDom, Canvas.

Installation

  1. npm i express-route-sanitizer-middleware

  2. import into your Express app main file.

  3. use as a middle-ware on a specific route/controller

Example

const app = express();
import sanitizer from "express-route-sanitizer-middleware";
// Requests to this route will first go through the sanitizer
app.use('/users', sanitizer, require('./controllers/users-api'));

app.listen(port);

That's it! The "Users" controller will now be sanitized by the middleware.