Gathering detailed insights and metrics for @casual-simulation/rate-limit-redis
Gathering detailed insights and metrics for @casual-simulation/rate-limit-redis
Gathering detailed insights and metrics for @casual-simulation/rate-limit-redis
Gathering detailed insights and metrics for @casual-simulation/rate-limit-redis
Casual Open Simulation for the Web
npm install @casual-simulation/rate-limit-redis
Typescript
Module System
Node Version
NPM Version
72.2
Supply Chain
99.3
Quality
82.9
Maintenance
100
Vulnerability
100
License
TypeScript (68.16%)
JavaScript (26.52%)
TeX (3.67%)
Vue (1.21%)
CSS (0.26%)
HTML (0.1%)
Shell (0.04%)
SCSS (0.02%)
Dockerfile (0.01%)
HCL (0.01%)
Total Downloads
14,538
Last Day
1
Last Week
90
Last Month
489
Last Year
5,041
NOASSERTION License
55 Stars
14,437 Commits
12 Forks
7 Watchers
296 Branches
15 Contributors
Updated on Aug 29, 2025
Latest Version
3.4.0
Package Id
@casual-simulation/rate-limit-redis@3.4.0
Unpacked Size
25.56 kB
Size
8.01 kB
File Count
20
NPM Version
lerna/8.0.0/node@v18.20.7+x64 (linux)
Node Version
18.20.7
Published on
Apr 05, 2025
Cumulative downloads
Total Downloads
Last Day
-50%
1
Compared to previous day
Last Week
373.7%
90
Compared to previous week
Last Month
25.4%
489
Compared to previous month
Last Year
-33.6%
5,041
Compared to previous year
4
rate-limit-redis
A redis
store for the
express-rate-limit
middleware.
From the npm registry:
1# Using npm 2> npm install rate-limit-redis 3# Using yarn or pnpm 4> yarn/pnpm add rate-limit-redis
From Github Releases:
1# Using npm 2> npm install https://github.com/wyattjoh/rate-limit-redis/releases/download/v{version}/rate-limit-redis.tgz 3# Using yarn or pnpm 4> yarn/pnpm add https://github.com/wyattjoh/rate-limit-redis/releases/download/v{version}/rate-limit-redis.tgz
Replace {version}
with the version of the package that you want to your, e.g.:
3.0.0
.
This library is provided in ESM as well as CJS forms, and works with both Javascript and Typescript projects.
This package requires you to use Node 14 or above.
Import it in a CommonJS project (type: commonjs
or no type
field in
package.json
) as follows:
1const RedisStore = require('rate-limit-redis');
Import it in a ESM project (type: module
in package.json
) as follows:
1import RedisStore from 'rate-limit-redis';
To use it with a node-redis
client:
1import rateLimit from 'express-rate-limit';
2import RedisStore from 'rate-limit-redis';
3import { createClient } from 'redis';
4
5// Create a `node-redis` client
6const client = createClient({
7 // ... (see https://github.com/redis/node-redis/blob/master/docs/client-configuration.md)
8});
9// Then connect to the Redis server
10await client.connect();
11
12// Create and use the rate limiter
13const limiter = rateLimit({
14 // Rate limiter configuration
15 windowMs: 15 * 60 * 1000, // 15 minutes
16 max: 100, // Limit each IP to 100 requests per `window` (here, per 15 minutes)
17 standardHeaders: true, // Return rate limit info in the `RateLimit-*` headers
18 legacyHeaders: false, // Disable the `X-RateLimit-*` headers
19
20 // Redis store configuration
21 store: new RedisStore({
22 sendCommand: (...args: string[]) => client.sendCommand(args),
23 }),
24});
25app.use(limiter);
To use it with a ioredis
client:
1import rateLimit from 'express-rate-limit';
2import RedisStore from 'rate-limit-redis';
3import RedisClient from 'ioredis';
4
5// Create a `ioredis` client
6const client = new RedisClient();
7// ... (see https://github.com/luin/ioredis#connect-to-redis)
8
9// Create and use the rate limiter
10const limiter = rateLimit({
11 // Rate limiter configuration
12 windowMs: 15 * 60 * 1000, // 15 minutes
13 max: 100, // Limit each IP to 100 requests per `window` (here, per 15 minutes)
14 standardHeaders: true, // Return rate limit info in the `RateLimit-*` headers
15 legacyHeaders: false, // Disable the `X-RateLimit-*` headers
16
17 // Redis store configuration
18 store: new RedisStore({
19 // @ts-expect-error - Known issue: the `call` function is not present in @types/ioredis
20 sendCommand: (...args: string[]) => client.call(...args),
21 }),
22});
23app.use(limiter);
sendCommand
The function used to send commands to Redis. The function signature is as follows:
1(...args: string[]) => Promise<number> | number
The raw command sending function varies from library to library; some are given below:
Library | Function |
---|---|
node-redis | async (...args: string[]) => client.sendCommand(args) |
ioredis | async (...args: string[]) => client.call(...args) |
handy-redis | async (...args: string[]) => client.nodeRedis.sendCommand(args) |
tedis | async (...args: string[]) => client.command(...args) |
redis-fast-driver | async (...args: string[]) => client.rawCallAsync(args) |
yoredis | async (...args: string[]) => (await client.callMany([args]))[0] |
noderis | async (...args: string[]) => client.callRedis(...args) |
prefix
The text to prepend to the key in Redis.
Defaults to rl:
.
resetExpiryOnChange
Whether to reset the expiry for a particular key whenever its hit count changes.
Defaults to false
.
MIT © Wyatt Johnson
No vulnerabilities found.