{"_id":"@elithrar/workers-hono-rate-limit","_rev":"8-1b15ab4d42c6e96e1c15cc9cf70509cb","name":"@elithrar/workers-hono-rate-limit","dist-tags":{"latest":"0.5.1"},"versions":{"0.1.0":{"name":"@elithrar/workers-hono-rate-limit","version":"0.1.0","license":"Apache-2.0","_id":"@elithrar/workers-hono-rate-limit@0.1.0","maintainers":[{"name":"elithrar","email":"matt@eatsleeprepeat.net"}],"homepage":"https://github.com/elithrar/hono-cf-rate-limit","bugs":{"url":"https://github.com/elithrar/hono-cf-rate-limit/issues"},"dist":{"shasum":"faeab1d86715d61dc150b47fd4f21d63468086ca","tarball":"https://registry.npmjs.org/@elithrar/workers-hono-rate-limit/-/workers-hono-rate-limit-0.1.0.tgz","fileCount":6,"integrity":"sha512-kZkfcSDrGHCnbE675AZgwjAxTRc6RA8SCtJZzqSKRf+RGeuVLs4PESk/J6Ge1aI5NGQ5JhGfDgizoA/VbZIoPQ==","signatures":[{"sig":"MEQCIB+qN05b9kJOq9PixPWoexy5KMKApmituhc8Ti0F/J39AiBlIoSKwgLgAg2K5xKbisgYFnItKCusCzxBCKlGvPsG+A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16128},"main":"dist/index.mjs","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs","require":"./dist/index.mjs"}},"gitHead":"9da2978b85dc066a1de7f93d6b8b5b46212255ee","scripts":{"test":"vitest --run","build":"npx unbuild"},"_npmUser":{"name":"elithrar","email":"matt@eatsleeprepeat.net"},"repository":{"url":"git+https://github.com/elithrar/hono-cf-rate-limit.git","type":"git"},"_npmVersion":"10.2.4","description":"Hono-compatible middleware for rate limiting with Cloudflare Workers.","directories":{},"_nodeVersion":"21.5.0","dependencies":{"jest":"^29.7.0","@cloudflare/workers-types":"^4.20240405.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"devDependencies":{"hono":"^3.11.7","vitest":"^1.0.4","unbuild":"^2.0.0"},"peerDependencies":{"hono":"*"},"_npmOperationalInternal":{"tmp":"tmp/workers-hono-rate-limit_0.1.0_1713387761530_0.09673798651935939","host":"s3://npm-registry-packages"}},"0.2.0":{"name":"@elithrar/workers-hono-rate-limit","version":"0.2.0","license":"Apache-2.0","_id":"@elithrar/workers-hono-rate-limit@0.2.0","maintainers":[{"name":"elithrar","email":"matt@eatsleeprepeat.net"}],"homepage":"https://github.com/elithrar/hono-cf-rate-limit","bugs":{"url":"https://github.com/elithrar/hono-cf-rate-limit/issues"},"dist":{"shasum":"f3b33fcebd92f69f9277783a48d4cf240572bb27","tarball":"https://registry.npmjs.org/@elithrar/workers-hono-rate-limit/-/workers-hono-rate-limit-0.2.0.tgz","fileCount":6,"integrity":"sha512-/om+Sg3NXuIso3O+o0Cc2Bt7ym6AM9S3HWTexA8Bda2AVKELu4kfGbdzlhVfk2eE5ZqBTqB49clTRbUCqbLChQ==","signatures":[{"sig":"MEUCIQDsXUdOcYejci05LmSVjdhjgm2OImr6selfBRky0TWD1AIgEsSFfbNH19SSApbXBzCQrnKpctSKmYid8PhYqwtv+UY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15967},"main":"dist/index.mjs","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs","require":"./dist/index.mjs"}},"gitHead":"65a6647abfba8d4245905fdca57d4a16b461914d","scripts":{"test":"vitest --run","build":"npx unbuild"},"_npmUser":{"name":"elithrar","email":"matt@eatsleeprepeat.net"},"repository":{"url":"git+https://github.com/elithrar/hono-cf-rate-limit.git","type":"git"},"_npmVersion":"10.2.4","description":"Hono-compatible middleware for rate limiting requests with Cloudflare Workers.","directories":{},"_nodeVersion":"21.5.0","dependencies":{"jest":"^29.7.0","@cloudflare/workers-types":"^4.20240405.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"devDependencies":{"hono":"^3.11.7","vitest":"^1.0.4","unbuild":"^2.0.0"},"peerDependencies":{"hono":"*"},"_npmOperationalInternal":{"tmp":"tmp/workers-hono-rate-limit_0.2.0_1713441044665_0.5942619049943558","host":"s3://npm-registry-packages"}},"0.2.1":{"name":"@elithrar/workers-hono-rate-limit","version":"0.2.1","license":"Apache-2.0","_id":"@elithrar/workers-hono-rate-limit@0.2.1","maintainers":[{"name":"elithrar","email":"matt@eatsleeprepeat.net"}],"homepage":"https://github.com/elithrar/hono-cf-rate-limit","bugs":{"url":"https://github.com/elithrar/hono-cf-rate-limit/issues"},"dist":{"shasum":"c193e5dff46a9719dc8ee76a684790e5cf4e8655","tarball":"https://registry.npmjs.org/@elithrar/workers-hono-rate-limit/-/workers-hono-rate-limit-0.2.1.tgz","fileCount":6,"integrity":"sha512-E0YXeqdMXB44FMDRfCTZn6pxJWbTm/EnuU6V1kEE57IGRbF/MSkzgqiw2wDmBtbe4bAmW4/H6ZkZup8Vhguu1g==","signatures":[{"sig":"MEUCIC3aEqcJthMIwYRxe+Dd0z4bC79HFt+az7NJn4yBqIMiAiEAjjuzSSd7gFNHpsX/6yxVmBsuzXCS3qq9f0NqfLO9gGE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15886},"main":"dist/index.mjs","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs","require":"./dist/index.mjs"}},"gitHead":"65a6647abfba8d4245905fdca57d4a16b461914d","scripts":{"test":"vitest --run","build":"npx unbuild","publish":"npx unbuild && npm publish"},"_npmUser":{"name":"elithrar","email":"matt@eatsleeprepeat.net"},"repository":{"url":"git+https://github.com/elithrar/hono-cf-rate-limit.git","type":"git"},"_npmVersion":"10.2.4","description":"Hono-compatible middleware for rate limiting requests with Cloudflare Workers.","directories":{},"_nodeVersion":"21.5.0","dependencies":{"jest":"^29.7.0","@cloudflare/workers-types":"^4.20240405.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"devDependencies":{"hono":"^3.11.7","vitest":"^1.0.4","unbuild":"^2.0.0"},"peerDependencies":{"hono":"*"},"_npmOperationalInternal":{"tmp":"tmp/workers-hono-rate-limit_0.2.1_1713447658239_0.10835148905729586","host":"s3://npm-registry-packages"}},"0.3.0":{"name":"@elithrar/workers-hono-rate-limit","version":"0.3.0","license":"Apache-2.0","_id":"@elithrar/workers-hono-rate-limit@0.3.0","maintainers":[{"name":"elithrar","email":"matt@eatsleeprepeat.net"}],"homepage":"https://github.com/elithrar/hono-cf-rate-limit","bugs":{"url":"https://github.com/elithrar/hono-cf-rate-limit/issues"},"dist":{"shasum":"2f37789b1a5b10c638690a10df40564af5c8dc4b","tarball":"https://registry.npmjs.org/@elithrar/workers-hono-rate-limit/-/workers-hono-rate-limit-0.3.0.tgz","fileCount":6,"integrity":"sha512-6cyBqBEAKxvZZkrEIz4xKBgjqHUsiwyOuhVtH0nzlzgYEAhBcdd9cIX7hGFTaYnjOTy8aG9YUszs1hLqyIXH2Q==","signatures":[{"sig":"MEQCIBs9p6in8Enxo7MwacuFhZ+rSKeMTTqAtsQSrS6i7ngWAiBtJfgfmKXPJQBOuWo8ghXOydg8Tl+jkJ7g7jtunRNcBg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15886},"main":"dist/index.mjs","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs","require":"./dist/index.mjs"}},"gitHead":"65a6647abfba8d4245905fdca57d4a16b461914d","scripts":{"test":"vitest --run","build":"npx unbuild","publish":"npx unbuild && npm publish"},"_npmUser":{"name":"elithrar","email":"matt@eatsleeprepeat.net"},"repository":{"url":"git+https://github.com/elithrar/hono-cf-rate-limit.git","type":"git"},"_npmVersion":"10.2.4","description":"Hono-compatible middleware for rate limiting requests with Cloudflare Workers.","directories":{},"_nodeVersion":"21.5.0","dependencies":{"jest":"^29.7.0","@cloudflare/workers-types":"^4.20240405.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"devDependencies":{"hono":"^3.11.7","vitest":"^1.0.4","unbuild":"^2.0.0"},"peerDependencies":{"hono":"*"},"_npmOperationalInternal":{"tmp":"tmp/workers-hono-rate-limit_0.3.0_1713447676453_0.46161486870165125","host":"s3://npm-registry-packages"}},"0.4.0":{"name":"@elithrar/workers-hono-rate-limit","version":"0.4.0","license":"Apache-2.0","_id":"@elithrar/workers-hono-rate-limit@0.4.0","maintainers":[{"name":"elithrar","email":"matt@eatsleeprepeat.net"}],"homepage":"https://github.com/elithrar/hono-cf-rate-limit","bugs":{"url":"https://github.com/elithrar/hono-cf-rate-limit/issues"},"dist":{"shasum":"fdb4f3d726c8243bed956875e3c8d1308a6c53e1","tarball":"https://registry.npmjs.org/@elithrar/workers-hono-rate-limit/-/workers-hono-rate-limit-0.4.0.tgz","fileCount":6,"integrity":"sha512-ZW37oxJQrqZSwBElIgLoxwogU8dfM46HK1mt4q34m6HqI8aG7/tu9ObEWiav85nWYPbuHLb1F5czLHoXN7MLsA==","signatures":[{"sig":"MEUCIQDU0VVhAB3zBh+MqOj3xC5iALpUZjgUb4zwPQApAeUzIwIgfJ89L5YJijCv4TX3GOThvenpAL1lec9QZ+wOsSJ1rNI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15890},"main":"dist/index.mjs","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs","require":"./dist/index.mjs"}},"gitHead":"e7cf6256eb6749f21058cad622cd76141e9b3ed7","scripts":{"test":"vitest --run","build":"npx unbuild","publish":"npx unbuild && npm publish"},"_npmUser":{"name":"elithrar","email":"matt@eatsleeprepeat.net"},"repository":{"url":"git+https://github.com/elithrar/hono-cf-rate-limit.git","type":"git"},"_npmVersion":"10.2.4","description":"Hono-compatible middleware for rate limiting requests with Cloudflare Workers.","directories":{},"_nodeVersion":"21.5.0","dependencies":{"jest":"^29.7.0","@cloudflare/workers-types":"^4.20240405.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"devDependencies":{"hono":"^3.11.7","vitest":"^1.0.4","unbuild":"^2.0.0"},"peerDependencies":{"hono":"*"},"_npmOperationalInternal":{"tmp":"tmp/workers-hono-rate-limit_0.4.0_1713447831154_0.7761331736957282","host":"s3://npm-registry-packages"}},"0.4.1":{"name":"@elithrar/workers-hono-rate-limit","version":"0.4.1","license":"Apache-2.0","_id":"@elithrar/workers-hono-rate-limit@0.4.1","maintainers":[{"name":"elithrar","email":"matt@eatsleeprepeat.net"}],"homepage":"https://github.com/elithrar/hono-cf-rate-limit","bugs":{"url":"https://github.com/elithrar/hono-cf-rate-limit/issues"},"dist":{"shasum":"5282bf0c423162c6b11f99530376c97b00ab29ac","tarball":"https://registry.npmjs.org/@elithrar/workers-hono-rate-limit/-/workers-hono-rate-limit-0.4.1.tgz","fileCount":6,"integrity":"sha512-U7k/b9/SpI9kaO2+uu9XqhO2Ja8j0V48kDuuG2H0e47zf5IKMP/zKMgY06CzpRBB8O1keSDV5TxVHmqFYQ2p8w==","signatures":[{"sig":"MEYCIQDoQC0+U7ai229UMHTn8xnU6t87Vfjxr6BZhs+ZgRG17gIhANDbDi822m9Z5VOErHp0A3M4cjS086GPdnZl+4vajjhP","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16680},"main":"dist/index.mjs","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs","require":"./dist/index.mjs"}},"gitHead":"b83eec752ff7a4bc4202cd30dc6901377857ef80","scripts":{"test":"vitest --run","build":"npx unbuild","publish":"npx unbuild"},"_npmUser":{"name":"elithrar","email":"matt@eatsleeprepeat.net"},"repository":{"url":"git+https://github.com/elithrar/hono-cf-rate-limit.git","type":"git"},"_npmVersion":"10.2.4","description":"Hono-compatible middleware for rate limiting requests with Cloudflare Workers.","directories":{},"_nodeVersion":"21.5.0","dependencies":{"jest":"^29.7.0","@cloudflare/workers-types":"^4.20240405.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"devDependencies":{"hono":"^3.11.7","vitest":"^1.0.4","unbuild":"^2.0.0","@types/jest":"^29.5.12"},"peerDependencies":{"hono":"*"},"_npmOperationalInternal":{"tmp":"tmp/workers-hono-rate-limit_0.4.1_1713449035044_0.201271434283826","host":"s3://npm-registry-packages"}},"0.4.3":{"name":"@elithrar/workers-hono-rate-limit","version":"0.4.3","license":"Apache-2.0","_id":"@elithrar/workers-hono-rate-limit@0.4.3","maintainers":[{"name":"elithrar","email":"matt@eatsleeprepeat.net"}],"homepage":"https://github.com/elithrar/hono-cf-rate-limit","bugs":{"url":"https://github.com/elithrar/hono-cf-rate-limit/issues"},"dist":{"shasum":"d2460f304374f464ee30227f8aec9947523d8201","tarball":"https://registry.npmjs.org/@elithrar/workers-hono-rate-limit/-/workers-hono-rate-limit-0.4.3.tgz","fileCount":8,"integrity":"sha512-0uo485axFr7UcjuWu/nwkM8BlklVyBAKG6VxdrOECW6kviG1VaHeT+Ui+Y9/rFqy6SzlWfvlKech0R34P3coFg==","signatures":[{"sig":"MEYCIQDAzzTU1YNFpLy/NIp1setdBnWGv39lBexKcim3mn7dKAIhAPZIPpufC5YWpO/Djf//20RI5eOKkPST53Lo4vxabGjN","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18631},"main":"dist/index.cjs","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.cjs"}},"gitHead":"a596e706dca5b699281cd20f070abe1a33a5d6d7","scripts":{"test":"vitest --run","build":"npx unbuild","publish":"npx unbuild"},"_npmUser":{"name":"elithrar","email":"matt@eatsleeprepeat.net"},"repository":{"url":"git+https://github.com/elithrar/hono-cf-rate-limit.git","type":"git"},"_npmVersion":"10.2.4","description":"Hono-compatible middleware for rate limiting requests with Cloudflare Workers.","directories":{},"_nodeVersion":"21.5.0","dependencies":{"jest":"^29.7.0","@cloudflare/workers-types":"^4.20240405.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"_hasShrinkwrap":false,"devDependencies":{"hono":"^3.12.12","vitest":"^1.0.4","unbuild":"^2.0.0","@types/jest":"^29.5.12"},"peerDependencies":{"hono":"*"},"_npmOperationalInternal":{"tmp":"tmp/workers-hono-rate-limit_0.4.3_1713978990046_0.7188693226452583","host":"s3://npm-registry-packages"}},"0.5.1":{"name":"@elithrar/workers-hono-rate-limit","version":"0.5.1","type":"module","description":"Hono-compatible middleware for rate limiting requests with Cloudflare Workers.","scripts":{"test":"vitest run","build":"npx unbuild","publish":"npx unbuild"},"exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.cjs"}},"main":"dist/index.cjs","module":"dist/index.mjs","types":"dist/index.d.ts","license":"Apache-2.0","publishConfig":{"registry":"https://registry.npmjs.org","access":"public"},"repository":{"type":"git","url":"git+https://github.com/elithrar/workers-hono-rate-limit.git"},"homepage":"https://github.com/elithrar/workers-hono-rate-limit","peerDependencies":{"hono":">=4.0.0"},"devDependencies":{"@cloudflare/vitest-pool-workers":"^0.11.1","@cloudflare/workers-types":"^4.20251225.0","hono":"^4.11.2","unbuild":"^3.6.1","vitest":"^3.2.0","wrangler":"^4.54.0"},"gitHead":"80174e6555a21bf6dd50aa66421a9925b955cc24","_id":"@elithrar/workers-hono-rate-limit@0.5.1","bugs":{"url":"https://github.com/elithrar/workers-hono-rate-limit/issues"},"_nodeVersion":"25.2.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-DKOxeQxyIHuVnD7fqWUhg2KxFchjUCnbmWmrXY/9jnAN67C1s7k2ABvKI4Iavv7D0Pt08tbMOKB1fLAb3wioBw==","shasum":"ee468fbc7a85f38c4e3558544363bb75fec51c1b","tarball":"https://registry.npmjs.org/@elithrar/workers-hono-rate-limit/-/workers-hono-rate-limit-0.5.1.tgz","fileCount":6,"unpackedSize":16775,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC5jLHqJ4zRPYXHtfB0N5gy/xm7Wx2wfZo+LZZNA+ekTQIgaivhxOkYUGE7mvwLT5/S8/UufMKt2p9BGPPoXE6CY+I="}]},"_npmUser":{"name":"elithrar","email":"matt@eatsleeprepeat.net"},"directories":{},"maintainers":[{"name":"elithrar","email":"matt@eatsleeprepeat.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/workers-hono-rate-limit_0.5.1_1766694882388_0.7701141009294461"},"_hasShrinkwrap":false}},"time":{"created":"2024-04-17T21:02:41.417Z","modified":"2025-12-25T20:34:42.718Z","0.1.0":"2024-04-17T21:02:41.705Z","0.2.0":"2024-04-18T11:50:44.802Z","0.2.1":"2024-04-18T13:40:58.387Z","0.3.0":"2024-04-18T13:41:16.596Z","0.4.0":"2024-04-18T13:43:51.307Z","0.4.1":"2024-04-18T14:03:55.214Z","0.4.3":"2024-04-24T17:16:30.213Z","0.5.1":"2025-12-25T20:34:42.531Z"},"bugs":{"url":"https://github.com/elithrar/workers-hono-rate-limit/issues"},"license":"Apache-2.0","homepage":"https://github.com/elithrar/workers-hono-rate-limit","repository":{"type":"git","url":"git+https://github.com/elithrar/workers-hono-rate-limit.git"},"description":"Hono-compatible middleware for rate limiting requests with Cloudflare Workers.","maintainers":[{"name":"elithrar","email":"matt@eatsleeprepeat.net"}],"readme":"# @elithrar/workers-hono-rate-limit\n\n[![Build & Test](https://github.com/elithrar/workers-hono-rate-limit/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/elithrar/workers-hono-rate-limit/actions/workflows/test.yml)\n\nHono middleware for Cloudflare Worker's [rate limiting bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/).\n\n## Install\n\n```sh\nnpm install @elithrar/workers-hono-rate-limit\n```\n\n## Usage\n\n1. Add a rate limiting binding to your `wrangler.toml` (or `wrangler.jsonc`)\n2. Define a `RateLimitKeyFunc` that returns the key to rate limit on\n3. Apply the `rateLimit` middleware to your routes\n\n```toml\n# wrangler.toml\n\n[[ratelimits]]\nbinding = \"RATE_LIMITER\"\nnamespace_id = \"1001\"\n# 25 requests per 10 seconds\nsimple = { limit = 25, period = 10 }\n```\n\n```ts\nimport { rateLimit, RateLimitBinding, RateLimitKeyFunc } from \"@elithrar/workers-hono-rate-limit\";\nimport { Hono } from \"hono\";\n\ntype Bindings = {\n\tRATE_LIMITER: RateLimitBinding;\n};\n\nconst app = new Hono<{ Bindings: Bindings }>();\n\n// Rate limit on each API token\nconst getKey: RateLimitKeyFunc = (c) => c.req.header(\"Authorization\") || \"\";\n\n// Apply rate limiting to all routes\napp.use(\"*\", (c, next) => rateLimit(c.env.RATE_LIMITER, getKey)(c, next));\n\napp.get(\"/\", (c) => c.text(\"hello!\"));\n\nexport default app;\n```\n\nYou can create multiple `rateLimit` instances with different configurations and key functions for each use-case, or apply the same instance to multiple route patterns via `app.use`.\n\n### Async Key Functions\n\nThe `keyFunc` can also be async if you need to look up user information:\n\n```ts\nconst getKey: RateLimitKeyFunc = async (c) => {\n\tconst user = await validateToken(c.req.header(\"Authorization\"));\n\treturn user?.id || \"\";\n};\n```\n\n## Notes\n\n- The key should represent a unique characteristic of a user or class of user. Good choices include API keys, user IDs, or tenant IDs.\n- Avoid using IP addresses or locations as keys—these can be shared by many users.\n- If your `keyFunc` returns an empty string, rate limiting is bypassed for that request.\n\n## License\n\nApache 2.0 licensed. See the LICENSE file for details.\n","readmeFilename":"README.md"}