{"id":20878940,"url":"https://github.com/perongh/smooth-rate","last_synced_at":"2026-04-29T12:36:09.947Z","repository":{"id":172591491,"uuid":"649481981","full_name":"PeronGH/smooth-rate","owner":"PeronGH","description":"A Redis-agnostic, flexible, and easy-to-use rate limiting module for Deno, utilizing a sliding window algorithm.","archived":false,"fork":false,"pushed_at":"2023-06-08T14:18:42.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-19T09:42:20.778Z","etag":null,"topics":["deno","ratelimit","redis","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/PeronGH.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}},"created_at":"2023-06-05T00:59:31.000Z","updated_at":"2023-06-05T13:10:49.000Z","dependencies_parsed_at":"2023-12-31T05:15:32.929Z","dependency_job_id":null,"html_url":"https://github.com/PeronGH/smooth-rate","commit_stats":null,"previous_names":["perongh/smooth-rate"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeronGH%2Fsmooth-rate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeronGH%2Fsmooth-rate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeronGH%2Fsmooth-rate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeronGH%2Fsmooth-rate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PeronGH","download_url":"https://codeload.github.com/PeronGH/smooth-rate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243258005,"owners_count":20262294,"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":["deno","ratelimit","redis","typescript"],"created_at":"2024-11-18T07:14:40.123Z","updated_at":"2025-12-25T12:24:50.276Z","avatar_url":"https://github.com/PeronGH.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# smooth-rate\n\nA Redis-agnostic rate limiting module for Deno applications. smooth-rate offers a simple and adaptable interface for managing operation rates, making it an ideal solution for high-concurrency environments.\n\n## Features\n\n- **Redis-Agnostic**: Built to integrate with any Redis library, offering freedom to choose or switch your Redis library as per your needs.\n  \n- **Sliding Window Algorithm**: Implements the sliding window algorithm for precise and fluid rate limits, that transition smoothly over time rather than resetting periodically.\n\n- **Flexible Configuration**: Easy customization of key prefix, window size, and max requests to adapt to diverse rate limiting requirements.\n\n- **Atomic Operations**: Each operation is atomic, ensuring consistent results in a concurrent environment.\n\n## Basic Usage\n\nImport the `RateLimiter` class from the module:\n\n```typescript\nimport { RateLimiter } from 'https://deno.land/x/smooth_rate/mod.ts';\n```\n\nCreate an instance of `RateLimiter`:\n\n```typescript\nconst rateLimiter = new RateLimiter({\n  keyPrefix: 'ratelimit',\n  windowMs: 60 * 1000, // 60 seconds\n  maxRequests: 100,\n  redis: {\n    // Take `x/redis` as an example\n    async eval(script, keys, args) {\n      const raw = await redis.eval(script, keys, args);\n      return raw!.toString();\n    },\n    async del(key) {\n      await redis.del(key);\n    },\n  },\n});\n```\n\nUse the `limit` and `check` methods:\n\n```typescript\n// Limit a request\nconst limitResult = await rateLimiter.limit('someIdentifier');\n\n// Check the rate limit status\nconst checkResult = await rateLimiter.check('someIdentifier');\n```\n\nBoth `limit` and `check` return a `RateLimitInfo` object:\n\n- `isLimited`: Is the identifier currently limited?\n- `nextAvailableTimestamp`: When is the next request allowed?\n- `remainingRequests`: How many requests remain for the current window?\n\nUse `reset` to reset the rate limit for an identifier:\n\n```typescript\nawait rateLimiter.reset('someIdentifier');\n```\n\n## Contributing\n\nContributions are welcome. Open an issue or pull request on GitHub.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperongh%2Fsmooth-rate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperongh%2Fsmooth-rate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperongh%2Fsmooth-rate/lists"}