ExpressJS middleware that allows handling custom MongoDB queries sent from the client via HTTP query parameters. Current stable version is 1.1.2, last updated in 2020. The middleware parses a JSON string from a query parameter (default: 'filter') and attaches it to req.query, enabling direct MongoDB query syntax in HTTP requests. No built-in security filtering – explicit documentation warns that input must be sanitized manually, a critical footgun. Supports common MongoDB operators ($or, $and, $ne, $regex, etc.) and allows custom configuration for parameter name, error class, and operator whitelist/blacklist. Lightweight, no dependencies. Differentiator: minimalistic approach vs. more opinionated query-parsing alternatives like 'express-query-filter'.
npm install express-mongodb-filtersNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic Express server using the middleware to parse a MongoDB filter from query parameter 'filter' and use it in a Mongoose query. Includes explicit security warning.
Always validate and sanitize the parsed filter object before passing to MongoDB queries. Use library like 'mongo-sanitize' or manually whitelist allowed fields and operators.
Either use a different parameterName to avoid collision, or store the original string before the middleware runs.
Either provide a customErrorClass that inherits from Error, or add an Express error-handling middleware to catch and respond gracefully.
Consider migrating to actively maintained alternative or fork the package to apply patches.
Use require('express-mongodb-filters') instead of import.Ensure filter parameter is a JSON string, e.g., ?filter={"hello":1}Run `npm install express-mongodb-filters` in your project directory.
No dependency data recorded yet.