express-route-sanitizer-middleware

1.0.4 • Public • Published

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.

Package Sidebar

Install

npm i express-route-sanitizer-middleware

Weekly Downloads

3

Version

1.0.4

License

ISC

Unpacked Size

3.2 kB

Total Files

3

Last publish

Collaborators

  • avih92