express-rate-limit-ioredis-store
v1.0.4
Published
A redis store implementation to be used alongside ioredis for the express-rate-limit middleware
Downloads
213
Maintainers
Readme
Express Rate Limit IORedis store
A redis store implementation to be used alongside ioredis for the Express Rate Limit middleware. Since the existing redis store is not natively typed and seemed to be using the legacy store version of the Express Rate Limit, I decided to implement a new store for my personal projects. There is a disavantage to rate-limit-redis, in which this store only works with the IORedis client.
Installation
With npm:
$ npm install --save express-rate-limit-ioredis-store
With yarn:
$ yarn add express-rate-limit-ioredis-store
Usage
const ExpressRateLimit = require("express-rate-limit");
const RedisStore = require("express-rate-limit-ioredis-store");
const limiter = ExpressRateLimit({
store: new RedisStore({
// check Options
}),
max: 100,
windowMs: 60000,
});
app.use(limiter);
Or with ES modules
import ExpressRateLimit from 'express-rate-limit';
import RedisStore from 'express-rate-limit-ioredis-store';
const limiter = ExpressRateLimit({
store: new RedisStore({
// check Options
}),
max: 100,
windowMs: 60000,
});
app.use(limiter);
Options
- globalPrefix: string (optional) - the prefix that will be added to all the redis keys used by this lib. Default value is
express-rate-limit-store-
. - client: The ioredis Client to be used by the store.
Licence
MIT (c) 2022 Gustavo Soviersovski