{"library":"rate-limit-redis","title":"Redis Store for Express Rate Limit","description":"rate-limit-redis is a Redis-backed storage engine designed for the `express-rate-limit` middleware, enabling distributed rate limiting across multiple application instances. It is currently at stable version 4.3.1, with frequent minor and patch releases, as indicated by the recent changelog entries, reflecting an active maintenance schedule. This library supports popular Redis clients such as `node-redis` and `ioredis`, and also explicitly lists compatibility with `redict` and `valkey`, offering flexibility in deployment. A key differentiator is its flexible `sendCommand` abstraction, which allows seamless integration with various Redis client libraries by adapting their specific command execution functions. It requires Node.js 16 or above and Redis 2.6.12 or above for operation. The project maintains an active development status, ensuring compatibility with the latest `express-rate-limit` versions and modern Node.js environments.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install rate-limit-redis"],"cli":null},"imports":["import { RedisStore } from 'rate-limit-redis'","import type { RedisStore } from 'rate-limit-redis'","import type { RedisReply } from 'rate-limit-redis'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { rateLimit } from 'express-rate-limit';\nimport { RedisStore } from 'rate-limit-redis';\nimport { createClient } from 'redis';\nimport express from 'express';\n\nconst app = express();\n\nasync function setupRateLimiter() {\n  // Create a `node-redis` client\n  const client = createClient({\n    url: process.env.REDIS_URL ?? 'redis://localhost:6379'\n  });\n\n  // Then connect to the Redis server\n  client.on('error', (err) => console.error('Redis Client Error', err));\n  await client.connect();\n  console.log('Connected to Redis');\n\n  // Create and use the rate limiter\n  const limiter = rateLimit({\n    windowMs: 15 * 60 * 1000, // 15 minutes\n    max: 100, // Limit each IP to 100 requests per window\n    standardHeaders: true, // Return rate limit info in the `RateLimit-*` headers\n    legacyHeaders: false, // Disable the `X-RateLimit-*` headers\n\n    // Redis store configuration\n    store: new RedisStore({\n      sendCommand: (...args: string[]) => client.sendCommand(args),\n    }),\n  });\n\n  app.use(limiter);\n\n  app.get('/', (req, res) => {\n    res.send('Hello, you are rate-limited!');\n  });\n\n  const PORT = process.env.PORT || 3000;\n  app.listen(PORT, () => {\n    console.log(`Server running on http://localhost:${PORT}`);\n  });\n}\n\nsetupRateLimiter().catch(console.error);","lang":"typescript","description":"Demonstrates setting up an Express application with rate limiting using Redis as a store, configured with the node-redis client. It connects to Redis and applies the rate limiter to all routes.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}