Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 

README.md

express-sanitize-middleware NPM version

Sanitize Express request body, query, param, and headers.

Heads up! This package wraps MapBox's port of Google's Caja sanitizer. Please see the aforementioned repository for details on the actual sanitization functionality.

Installation

# Via NPM
npm install express-sanitize-middleware --save

# Via Yarn
yarn add express-sanitize-middleware

Getting Started

express-sanitize-middleware exposes one function sanitizeRequest.

It can be used anywhere Express middleware can.

Example: sanitize request body

const express = require('express');
const sanitizeRequest = require('../middleware/express-sanitize-middleware');

const router = express.Router();

router.post('/', [
  sanitizeRequest({
    body: true
  }),
], (req, res, next) => {
  return res.json({message: 'Request body sanitized!'});
});

API Reference

sanitizeRequest(options)

The options argument is required and should contain at least one key dictacting what request property to sanitize.

Option key Default
body false
header false
params false
query false

License

MIT License Copyright (c) 2018 Joel Colucci

About

Sanitize Express request body, query, param, headers

Topics

Resources

License

Packages

No packages published