IP rate-limiting middleware for Koa2, inspired by express-rate-limit. Version 1.1.3 supports Redis, MongoDB (via Mongoose), and Sequelize stores. Release cadence is low; last significant update was in 2020. Differentiators: async/await, flexible interval config (ms or object), per-route keys, and delay-after behavior for throttling. Requires Node >=7.10 and peer deps for advanced stores.
npm install koa2-ratelimitVerified import paths — ran on the pinned version, not inferred.
Basic Koa2 app with rate limiting: 100 requests per 15 minutes per IP.
Update to v1.0.0+ and remove `messageKey` from options. Override `message` as a function to customize response.
Add `prefixKey` to your middleware options, e.g., `prefixKey: 'my-route'`.
Remove `delayAfter` and `timeWait`; use rate-only limiting.
Install `npm install redis@4` and update client configuration to v4 style.
Install `@types/koa2-ratelimit` or declare module manually.
Run `npm install redis@4` in your project.
Use number (milliseconds) or object like `{ hour: 1 }`. See docs for supported units.Use `RateLimit.middleware(options)` only once.
Add `prefixKey: 'someKey'` to middleware options.