Express.js middleware that filters incoming request URLs and HTML body contents for forbidden characters, words, or patterns, providing protection against NoSQL (e.g., MongoDB) injection attacks. Version 1.1.2 is the latest stable release; the package is stable but rarely updated. It does not depend on NoSQL and can be used for general content filtering. Unlike mongo-sanitize, which requires manual usage at each query, this middleware works globally at the app level. Requires body-parser as a peer dependency.
npm install content-filterNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to integrate content-filter as Express middleware, including required body-parser setup.
npm install body-parser and use app.use(bodyParser.json()) and app.use(bodyParser.urlencoded({extended:true})) before the filter.Use app.use(filter()) instead of app.use(filter).
Replace app.use(filter) with app.use(filter())
Ensure body-parser is installed and the middleware is added before content-filter.