mongo-rate-limit-store
v1.0.1
Published
Provides a Mongo store for the express-rate-limit middleware.
Downloads
46
Maintainers
Readme
Mongo Rate Limit Store
MongoDB store implementation for express-rate-limit package.
This project is fork of the rate-limit-mongo
Install
npm install mongo-rate-limit-store
Getting Started
import { rateLimit } from 'express-rate-limit'
import MongoStore from 'mongo-rate-limit-store'
const limiter = rateLimit({
store: new MongoStore({
windowsMs: 15 * 60 * 1000,
prefix: 'mongo_rl_',
uri: 'mongodb://localhost:27017',
}),
max: 100,
// should match the windowMs
windowMs: 15 * 60 * 1000,
})
// apply to all requests
app.use(limiter)
Implementation
MongoStore class is suitable with the express-rate-limit's Store
interface. You can check the offical documentation about creating custom stores for express-rate-limit from here.