{"id":13527625,"url":"https://github.com/express-rate-limit/rate-limit-redis","last_synced_at":"2025-05-14T21:10:49.152Z","repository":{"id":37270694,"uuid":"59141999","full_name":"express-rate-limit/rate-limit-redis","owner":"express-rate-limit","description":"A rate limiting store for express-rate-limit with Redis/Redict/Valkey/etc.","archived":false,"fork":false,"pushed_at":"2025-04-23T01:47:31.000Z","size":1995,"stargazers_count":192,"open_issues_count":6,"forks_count":36,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-23T02:35:14.069Z","etag":null,"topics":["express","express-js","express-middleware","expressjs","node","node-js","nodejs","rate-limit","rate-limiter","rate-limiting","ratelimit","ratelimiter","ratelimiting","redict","redis","valkey"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/rate-limit-redis","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/express-rate-limit.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":"contributing.md","funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"wyattjoh"}},"created_at":"2016-05-18T18:40:38.000Z","updated_at":"2025-04-23T01:47:33.000Z","dependencies_parsed_at":"2024-12-05T23:02:56.746Z","dependency_job_id":"5e8073be-d1e8-44bb-a799-d0a73e842a20","html_url":"https://github.com/express-rate-limit/rate-limit-redis","commit_stats":{"total_commits":110,"total_committers":22,"mean_commits":5.0,"dds":0.6545454545454545,"last_synced_commit":"e45bd948da4014862f14c811c9f46cb2cdd49374"},"previous_names":["wyattjoh/rate-limit-redis"],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/express-rate-limit%2Frate-limit-redis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/express-rate-limit%2Frate-limit-redis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/express-rate-limit%2Frate-limit-redis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/express-rate-limit%2Frate-limit-redis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/express-rate-limit","download_url":"https://codeload.github.com/express-rate-limit/rate-limit-redis/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254227631,"owners_count":22035671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["express","express-js","express-middleware","expressjs","node","node-js","nodejs","rate-limit","rate-limiter","rate-limiting","ratelimit","ratelimiter","ratelimiting","redict","redis","valkey"],"created_at":"2024-08-01T06:01:54.507Z","updated_at":"2025-05-14T21:10:44.138Z","avatar_url":"https://github.com/express-rate-limit.png","language":"TypeScript","funding_links":["https://github.com/sponsors/wyattjoh"],"categories":["TypeScript"],"sub_categories":[],"readme":"# \u003cdiv align=\"center\"\u003e `rate-limit-redis` \u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\t\u003cimg alt=\"Github Workflow Status\" src=\"https://github.com/express-rate-limit/rate-limit-redis/actions/workflows/ci.yaml/badge.svg\"/\u003e\n\t\u003cimg alt=\"npm version\" src=\"https://img.shields.io/npm/v/rate-limit-redis.svg\"/\u003e\n\t\u003cimg alt=\"GitHub Stars\" src=\"https://img.shields.io/github/stars/express-rate-limit/rate-limit-redis\"/\u003e\n\t\u003cimg alt=\"npm downloads\" src=\"https://img.shields.io/npm/dm/rate-limit-redis\"/\u003e\n\u003c/div\u003e\n\n\u003cbr\u003e\n\n\u003cdiv align=\"center\"\u003e\n\nA [`redis`](https://github.com/redis/redis) store for the\n[`express-rate-limit`](https://github.com/nfriedly/express-rate-limit)\nmiddleware. Also supports [`redict`](https://redict.io/) \u0026\n[`valkey`](https://valkey.io/).\n\n\u003c/div\u003e\n\n## Installation\n\nFrom the npm registry:\n\n```sh\n# Using npm\n\u003e npm install rate-limit-redis\n# Using yarn or pnpm\n\u003e yarn/pnpm add rate-limit-redis\n```\n\nFrom Github Releases:\n\n```sh\n# Using npm\n\u003e npm install https://github.com/express-rate-limit/rate-limit-redis/releases/download/v{version}/rate-limit-redis.tgz\n# Using yarn or pnpm\n\u003e yarn/pnpm add https://github.com/express-rate-limit/rate-limit-redis/releases/download/v{version}/rate-limit-redis.tgz\n```\n\nReplace `{version}` with the version of the package that you want to use, e.g.:\n`3.0.0`.\n\n## Usage\n\n### Importing\n\nThis library is provided in ESM as well as CJS forms, and works with both\nJavascript and Typescript projects.\n\n**This package requires you to use Node 16 or above.**\n\nImport it in a CommonJS project (`type: commonjs` or no `type` field in\n`package.json`) as follows:\n\n```ts\nconst { RedisStore } = require('rate-limit-redis')\n```\n\nImport it in a ESM project (`type: module` in `package.json`) as follows:\n\n```ts\nimport { RedisStore } from 'rate-limit-redis'\n```\n\n### Examples\n\nTo use it with a [`node-redis`](https://github.com/redis/node-redis) client:\n\n```ts\nimport { rateLimit } from 'express-rate-limit'\nimport { RedisStore } from 'rate-limit-redis'\nimport { createClient } from 'redis'\n\n// Create a `node-redis` client\nconst client = createClient({\n\t// ... (see https://github.com/redis/node-redis/blob/master/docs/client-configuration.md)\n})\n// Then connect to the Redis server\nawait client.connect()\n\n// Create and use the rate limiter\nconst limiter = rateLimit({\n\t// Rate limiter configuration\n\twindowMs: 15 * 60 * 1000, // 15 minutes\n\tmax: 100, // Limit each IP to 100 requests per `window` (here, per 15 minutes)\n\tstandardHeaders: true, // Return rate limit info in the `RateLimit-*` headers\n\tlegacyHeaders: false, // Disable the `X-RateLimit-*` headers\n\n\t// Redis store configuration\n\tstore: new RedisStore({\n\t\tsendCommand: (...args: string[]) =\u003e client.sendCommand(args),\n\t}),\n})\napp.use(limiter)\n```\n\nTo use it with a [`ioredis`](https://github.com/luin/ioredis) client:\n\n```ts\nimport { rateLimit } from 'express-rate-limit'\nimport { RedisStore } from 'rate-limit-redis'\nimport RedisClient from 'ioredis'\n\n// Create a `ioredis` client\nconst client = new RedisClient()\n// ... (see https://github.com/luin/ioredis#connect-to-redis)\n\n// Create and use the rate limiter\nconst limiter = rateLimit({\n\t// Rate limiter configuration\n\twindowMs: 15 * 60 * 1000, // 15 minutes\n\tmax: 100, // Limit each IP to 100 requests per `window` (here, per 15 minutes)\n\tstandardHeaders: true, // Return rate limit info in the `RateLimit-*` headers\n\tlegacyHeaders: false, // Disable the `X-RateLimit-*` headers\n\n\t// Redis store configuration\n\tstore: new RedisStore({\n\t\tsendCommand: (command: string, ...args: string[]) =\u003e\n\t\t\tclient.send_command(command, ...args),\n\t}),\n})\napp.use(limiter)\n```\n\n### Configuration\n\n#### `sendCommand`\n\nThe function used to send commands to Redis. The function signature is as\nfollows:\n\n```ts\n;(...args: string[]) =\u003e Promise\u003cnumber\u003e | number\n```\n\nThe raw command sending function varies from library to library; some are given\nbelow:\n\n| Library                                                            | Function                                                                              |\n| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------- |\n| [`node-redis`](https://github.com/redis/node-redis)                | `async (...args: string[]) =\u003e client.sendCommand(args)`                               |\n| [`ioredis`](https://github.com/luin/ioredis)                       | `async (command: string, ...args: string[]) =\u003e client.send_command(command, ...args)` |\n| [`handy-redis`](https://github.com/mmkal/handy-redis)              | `async (...args: string[]) =\u003e client.nodeRedis.sendCommand(args)`                     |\n| [`tedis`](https://github.com/silkjs/tedis)                         | `async (...args: string[]) =\u003e client.command(...args)`                                |\n| [`redis-fast-driver`](https://github.com/h0x91b/redis-fast-driver) | `async (...args: string[]) =\u003e client.rawCallAsync(args)`                              |\n| [`yoredis`](https://github.com/djanowski/yoredis)                  | `async (...args: string[]) =\u003e (await client.callMany([args]))[0]`                     |\n| [`noderis`](https://github.com/wallneradam/noderis)                | `async (...args: string[]) =\u003e client.callRedis(...args)`                              |\n\n#### `prefix`\n\nThe text to prepend to the key in Redict/Redis.\n\nDefaults to `rl:`.\n\n#### `resetExpiryOnChange`\n\nWhether to reset the expiry for a particular key whenever its hit count changes.\n\nDefaults to `false`.\n\n## License\n\nMIT © [Wyatt Johnson](https://github.com/wyattjoh),\n[Nathan Friedly](https://nfriedly.com),\n[Vedant K](https://github.com/gamemaker1)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpress-rate-limit%2Frate-limit-redis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexpress-rate-limit%2Frate-limit-redis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpress-rate-limit%2Frate-limit-redis/lists"}