express-mongo-sanitize support dryRun
option.
Please use express-mongo-sanitize.
Dry-Run mode for express-mongo-sanitize.
This express middleware does not drop sanitized property. Instead of it, It just calls report
function as callback.
express-mongo-sanitize drop invalid property from request.
I want to check that the application use $
and .
as valid case before introducing express-mongo-sanitize.
So, I want to get dry-run/report-only mode for express-mongo-sanitize.
Install with npm:
npm install express-mongo-sanitize-reporter
You can set report
option for this middleware.
It is dry-run mode.
import express from 'express';
import bodyParser from 'body-parser';
import mongoSanitize from 'express-mongo-sanitize-reporter';
const app = express();
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
// To report data, use:
app.use(mongoSanitize({
report: (req, key, value) => console.warn("This request will be invalid", req)
}));
Sanitizing mode:
import express from 'express';
import bodyParser from 'body-parser';
+ import mongoSanitize from 'express-mongo-sanitize';
- import mongoSanitize from 'express-mongo-sanitize-reporter';
const app = express();
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
// To remove data, use:
+ app.use(mongoSanitize());
- app.use(mongoSanitize({
- report: (req, key, value) => console.warn("This request will be invalid", req)
- }));
See Releases page.
Install devDependencies and Run npm test
:
npm test
Pull requests and stars are always welcome.
For bugs and feature requests, please create an issue.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
MIT © azu