MongoDB store adapter for express-brute, version 1.0.0. This package provides a persistent store for rate-limiting data using MongoDB. It is designed to work with the express-brute middleware in Express.js applications. The adapter uses an asynchronous function to provide a MongoDB collection reference. A key differentiator is its reliance on MongoDB TTL indexes for automatic expiration of rate-limit data. The package is stable but relies on the deprecated `mongodb` Node.js driver v2/3 style callbacks, not the newer async/await pattern. Expect minimal updates; it is in maintenance mode as express-brute itself is not actively developed.
npm install express-brute-mongoNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Complete setup of express-brute with MongoDB store, including MongoDB connection and rate-limiting a POST route.
Use mongodb driver version ^3.7 or adapt to newer driver that supports callback style, or wrap with a callback-based function.
Ensure you call ready() with a MongoDB collection object (e.g., db.collection('name')). Do not call ready with a database handle.Run this command in mongo shell: db.collection.createIndex({ expires: 1 }, { expireAfterSeconds: 0 });Consider using an alternative rate-limiting library like express-rate-limit with MongoDB via rate-limit-mongo.
Ensure you pass a MongoStore instance that has been properly initialized with a callback that calls ready() with a collection.
Create the TTL index: db.collection('bruteforce-store').createIndex({ expires: 1 }, { expireAfterSeconds: 0 });Call ready(db.collection('bruteforce-store')) not ready(db).