{"id":18368228,"url":"https://github.com/thinkjs/think-ratelimiter","last_synced_at":"2025-09-13T05:39:45.997Z","repository":{"id":73609643,"uuid":"117646566","full_name":"thinkjs/think-ratelimiter","owner":"thinkjs","description":"ThinkJS ratelimit middlewate","archived":false,"fork":false,"pushed_at":"2018-01-18T23:43:47.000Z","size":42,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-02-15T20:52:44.495Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/thinkjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2018-01-16T07:13:40.000Z","updated_at":"2019-02-28T09:37:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"01389877-232e-4159-9fed-5ea9d3ca7bcf","html_url":"https://github.com/thinkjs/think-ratelimiter","commit_stats":{"total_commits":5,"total_committers":2,"mean_commits":2.5,"dds":0.4,"last_synced_commit":"aa734545cdcdf067808234c81c045803c39ebb0d"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Fthink-ratelimiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Fthink-ratelimiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Fthink-ratelimiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Fthink-ratelimiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thinkjs","download_url":"https://codeload.github.com/thinkjs/think-ratelimiter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248281415,"owners_count":21077423,"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":[],"created_at":"2024-11-05T23:25:11.431Z","updated_at":"2025-04-10T19:37:22.538Z","avatar_url":"https://github.com/thinkjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# think-ratelimiter\nThinkJS ratelimit middlewate\n\n## Why use this middleware ?\n\nTo protect your applications from Brute Force Request.\n\n\n## Install\n\n`npm install think-ratelimiter`\n\n## How to use\n```js\n// in middleware.js\n\nconst redis = require('redis');\nconst { port, host, password } = think.config('redis');\nconst db = redis.createClient(port, host, { password });\nconst ratelimiter = require('think-ratelimiter');\n\nmodule.exports = {\n  // after router middleware\n  {\n    handle: ratelimit,\n    options: {\n      db,\n      errorMessage: 'Sometimes You Just Have To Slow Down',\n      headers: {\n        remaining: 'X-RateLimit-Remaining',\n        reset: 'X-RateLimit-Reset',\n        total: 'X-RateLimit-Limit'\n      },\n      resources: {\n        'test/test': {\n          id: ctx =\u003e ctx.ip,\n          max: 5,\n          duration: 7000 // ms\n        }\n      }\n    }\n  },\n}\n\n```\n\n## Attention\n\n* `X-Ratelimit-Reset` is Unix timestamp (Epoch seconds).\n* When users exceed the access limit HTTP response status will be `429 Too Many Request`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkjs%2Fthink-ratelimiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthinkjs%2Fthink-ratelimiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkjs%2Fthink-ratelimiter/lists"}