{"id":45900237,"url":"https://github.com/redis-developer/redis-ratelimiting-js","last_synced_at":"2026-02-27T22:24:44.986Z","repository":{"id":339490580,"uuid":"1151014022","full_name":"redis-developer/redis-ratelimiting-js","owner":"redis-developer","description":"This TypeScript app has  five different rate limiters, each using a different Redis data structure and algorithm. It serves a frontend that lets you test each rate limiting pattern.","archived":false,"fork":false,"pushed_at":"2026-02-27T20:58:01.000Z","size":71,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-27T20:59:54.488Z","etag":null,"topics":["node-redis","rate-limiter","rate-limiting","redis","redis-tutorials","typescript"],"latest_commit_sha":null,"homepage":"https://redis.io/tutorials/howtos/ratelimiting/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/redis-developer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-06T00:26:11.000Z","updated_at":"2026-02-27T20:57:32.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/redis-developer/redis-ratelimiting-js","commit_stats":null,"previous_names":["redis-developer/redis-ratelimiting-js"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/redis-developer/redis-ratelimiting-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redis-developer%2Fredis-ratelimiting-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redis-developer%2Fredis-ratelimiting-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redis-developer%2Fredis-ratelimiting-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redis-developer%2Fredis-ratelimiting-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/redis-developer","download_url":"https://codeload.github.com/redis-developer/redis-ratelimiting-js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redis-developer%2Fredis-ratelimiting-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29917457,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T19:37:42.220Z","status":"ssl_error","status_checked_at":"2026-02-27T19:37:41.463Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["node-redis","rate-limiter","rate-limiting","redis","redis-tutorials","typescript"],"created_at":"2026-02-27T22:24:44.431Z","updated_at":"2026-02-27T22:24:44.980Z","avatar_url":"https://github.com/redis-developer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"This is a [Redis](https://redis.io/) rate limiting demo for JS and [Node](https://nodejs.org/) using:\n\n- [Redis Cloud](https://redis.io/try-free/)\n- [Express](https://expressjs.com/)\n- [Handlebars](https://handlebarsjs.com/) + [HTMX](https://htmx.org/)\n\n\u003e **NOTE:** Read the [tutorial on rate limiters](https://redis.io/tutorials/howtos/ratelimiting/) for a guide.\n\n## Rate Limiting Algorithms\n\nThis demo implements five rate limiting algorithms, each backed by different Redis data structures:\n\n| Algorithm                  | Redis Data Structure                       | Description                                                                                                                                           |\n| -------------------------- | ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- |\n| **Fixed Window Counter**   | `STRING` (`INCR` + `EXPIRE`)               | Counts requests in fixed time windows. Simple but susceptible to boundary bursts.                                                                     |\n| **Sliding Window Log**     | `SORTED SET` (`ZADD` + `ZREMRANGEBYSCORE`) | Logs each request timestamp. Precise sliding window, but stores every request.                                                                        |\n| **Sliding Window Counter** | `STRING` x2 (weighted)                     | Weighted average of current and previous window counts. Smooths the fixed-window boundary problem.                                                    |\n| **Token Bucket**           | `HASH` + Lua script                        | Tokens refill at a steady rate; each request consumes one. Allows short bursts.                                                                       |\n| **Leaky Bucket**           | `HASH` + Lua script                        | Requests fill a bucket that leaks at a constant rate. Smooths traffic to steady output (shaping), or drops requests above the bucket size (policing). |\n\n## Requirements\n\n- [bun](https://bun.sh/)\n- [docker](https://www.docker.com/)\n  - Optional\n\n## Getting started\n\nCopy and edit the `.env` file:\n\n```bash\ncp .env.example .env\n```\n\nYour `.env` file should contain the connection string you copied from Redis Cloud.\n\nYour `.env.docker` file will look similar to `.env`, but should use the appropriate docker internal URLs. Here is\nan example:\n\n```bash\nREDIS_URL=\"redis://redis:6379\"\n```\n\nNext, spin up docker containers:\n\n```bash\nbun docker\n```\n\nYou should have a server running on `http://localhost:\u003cport\u003e` where the port is set in your `.env` file (default is 8080).\n\nOpen `http://localhost:8080` in your browser to see the demo UI. Each rate limiting algorithm has a card with:\n\n- **Send Request** -- sends a single request through the rate limiter\n- **Burst 10** -- sends 10 rapid requests to see the algorithm hit its limit\n- **Reset All Counters** -- clears all rate-limit keys from Redis\n\n### API Routes\n\n1. `POST /api/rate-limit/:algorithm` -- Test a single request against the named algorithm\n2. `POST /api/rate-limit/:algorithm/burst` -- Send 10 rapid requests against the named algorithm\n3. `POST /api/rate-limit/reset` -- Reset all rate-limit counters\n\nWhere `:algorithm` is one of: `fixed-window`, `sliding-window-log`, `sliding-window-counter`, `token-bucket`, `leaky-bucket`.\n\n## Running tests\n\nThere are some tests in the `__tests__` folder that can be run with the following command:\n\n```bash\nbun test\n```\n\nThese tests setup and teardown on their own. You can modify them if you want to leave data in Redis.\n\n## Running locally outside docker\n\nTo run the development server outside of docker:\n\n```bash\nbun install\n# then\nbun dev\n```\n\n## Other Scripts\n\nFormatting code:\n\n```bash\nbun format\n```\n\nUpdating dependencies:\n\n```bash\nbun update\n```\n\n## Connecting to Redis Cloud\n\nIf you don't yet have a database setup in Redis Cloud [get started here for free](https://redis.io/try-free/).\n\nThen follow the [Connect to a Redis Cloud database doc](https://redis.io/docs/latest/operate/rc/databases/connect/). You should end up with a connection string that looks like the string below:\n\n```bash\nREDIS_URL=\"redis://default:\u003cpassword\u003e@redis-#####.c###.us-west-2-#.ec2.redns.redis-cloud.com:#####\"\n```\n\nRun the [tests](#running-tests) to verify that you are connected properly.\n\n## Learn more\n\nTo learn more about Redis, take a look at the following resources:\n\n- [Redis Documentation](https://redis.io/docs/latest/) - learn about Redis products, features, and commands.\n- [Redis Tutorials](https://redis.io/tutorials/) - read tutorials, quick starts, and how-to guides for Redis.\n- [Redis Demo Center](https://redis.io/demo-center/) - watch short, technical videos about Redis products and features.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredis-developer%2Fredis-ratelimiting-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredis-developer%2Fredis-ratelimiting-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredis-developer%2Fredis-ratelimiting-js/lists"}