{"id":21744290,"url":"https://github.com/oeo/stopdude","last_synced_at":"2026-02-09T20:34:12.911Z","repository":{"id":263351142,"uuid":"890114930","full_name":"oeo/stopdude","owner":"oeo","description":"Another redis rate limiter","archived":false,"fork":false,"pushed_at":"2024-11-18T02:34:55.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-27T07:01:58.562Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/oeo.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":"2024-11-18T02:28:18.000Z","updated_at":"2024-11-18T02:34:58.000Z","dependencies_parsed_at":"2024-11-18T08:38:05.332Z","dependency_job_id":null,"html_url":"https://github.com/oeo/stopdude","commit_stats":null,"previous_names":["oeo/stopdude"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oeo/stopdude","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeo%2Fstopdude","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeo%2Fstopdude/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeo%2Fstopdude/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeo%2Fstopdude/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oeo","download_url":"https://codeload.github.com/oeo/stopdude/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oeo%2Fstopdude/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29280188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T19:05:41.198Z","status":"ssl_error","status_checked_at":"2026-02-09T19:05:37.449Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":[],"created_at":"2024-11-26T07:11:02.743Z","updated_at":"2026-02-09T20:34:12.894Z","avatar_url":"https://github.com/oeo.png","language":"JavaScript","readme":"# stopdude\n\nAnother Redis rate limiter.\n\n## Features\n\n- Supports minute, hour, day, week, and month-based rate limiting.\n- Built on top of Redis for high performance and scalability.\n\n## Install\n\nTo include StopDude in your project, run:\n\n```bash\nnpm install stopdude --save\n```\n\n## Usage\n\nHere's a basic example of how to use StopDude:\n\n```javascript\nconst StopDude = require('stopdude');\n\n// Initialize with custom options if needed\nconst options = {\n  redis: yourRedisClient, // Pass in a configured Redis client\n  prefix: 'yourPrefix',   // Optional: to namespace your keys in Redis\n};\n\nconst rateLimiter = new StopDude(options);\n\n// Example of creating a rate-limiting rule\nrateLimiter.create({ key: 'api_user_123', max: 100, time: 'hour' })\n  .then(() =\u003e {\n    console.log('Rule created successfully');\n  })\n  .catch(err =\u003e {\n    console.error('Error creating rule:', err);\n  });\n```\n\n## API\n\n### `create(options)`\n\n- Description: Creates a new rate-limiting rule.\n- Parameters:\n  - `options`: Object containing `key`, `max`, and `time`.\n  - `key`: String, the unique identifier for the rule.\n  - `max`: Number, the maximum number of allowed requests in the specified time.\n  - `time`: String, one of ['minute', 'hour', 'day', 'week', 'month'].\n- Returns: Promise that resolves with the created rule details.\n\n### `find(key)`\n\n- Description: Finds an existing rate limit rule by key.\n- Parameters:\n  - `key`: String, the unique identifier for the rule.\n- Returns: Promise that resolves with the rule details or `false` if not found.\n\n### `update(key, properties)`\n\n- Description: Updates an existing rate limit rule.\n- Parameters:\n  - `key`: String, the rule key to update.\n  - `properties`: Object containing properties to update (`max`, `time`).\n- Returns: Promise that resolves with `true` if update was successful.\n\n### `incr(key, amount)`\n\n- Description: Increments the counter for the specified rule key.\n- Parameters:\n  - `key`: String, the rule key to increment.\n  - `amount`: Number, the amount to increase by (default 1).\n- Returns: Promise that resolves with `true` if the increment was successful.\n\n### `stats(key)`\n\n- Description: Retrieves usage statistics for a rule.\n- Parameters:\n  - `key`: String, the rule key to retrieve stats for.\n- Returns: Promise that resolves with an object containing usage stats such as `counters`, `allowed`, and `percent` utilization.\n\n### `remove(key)`\n\n- Description: Removes a rate-limiting rule completely.\n- Parameters:\n  - `key`: String, the rule key to remove.\n- Returns: Promise that resolves with `true` if the rule was successfully removed.\n\n## Development\n\n- `yarn`: Install project dependencies.\n- `yarn test`: Run the test suite to ensure all functionality works as expected.\n- `yarn build`: Compile CoffeeScript source code to JavaScript for distribution.\n\n```\n  StopDude\n    create\n      ✔ should create a new rule\n      ✔ should throw an error for invalid time segment\n    find\n      ✔ should find an existing rule\n      ✔ should return false for non-existent rule\n    update\n      ✔ should update an existing rule\n    incr\n      ✔ should increment the counter\n    clear\n      ✔ should clear the counters\n    remove\n      ✔ should remove a rule\n    stats\n      ✔ should return stats for a rule\n      ✔ should return not allowed when max is reached\n    generateUUID\n      ✔ should generate a valid UUID\n    getExpires\n      ✔ should return a future timestamp for each time segment\n      ✔ should throw an error for invalid time segment\n    secsToTime\n      ✔ should convert a string to seconds\n    getTime\n      ✔ should return current unix timestamp\n    getMinute\n      ✔ should return the start of the current minute\n    getHour\n      ✔ should return the start of the current hour\n    getType\n      ✔ should return the type of an object\n\n\n  18 passing (19ms)\n\nDone in 0.34s.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foeo%2Fstopdude","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foeo%2Fstopdude","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foeo%2Fstopdude/lists"}