https://github.com/adiologydev/oak-rate-limit
Rate-limiting middleware for Oak server on Deno
https://github.com/adiologydev/oak-rate-limit
deno hacktoberfest rate-limiter
Last synced: 7 months ago
JSON representation
Rate-limiting middleware for Oak server on Deno
- Host: GitHub
- URL: https://github.com/adiologydev/oak-rate-limit
- Owner: adiologydev
- License: other
- Created: 2021-12-15T21:07:44.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-08-13T21:48:28.000Z (almost 2 years ago)
- Last Synced: 2025-11-09T23:20:34.534Z (8 months ago)
- Topics: deno, hacktoberfest, rate-limiter
- Language: TypeScript
- Homepage: https://deno.land/x/oak_rate_limit
- Size: 21.5 KB
- Stars: 16
- Watchers: 2
- Forks: 6
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# oak-rate-limit
[](https://github.com/denoland/deno)
[](https://discord.gg/cu8aMYw)
[](https://deno.land/x/oak_rate_limit)
Rate limiter for Oak Server on Deno
## Description
A Simple Rate Limiter for Oak Server on Deno inspired by express-rate-limit.
It's currently under development and if you'd like to contribute, feel free to
make a PR!
## Features
- Custom Cache Stores Support. Currently using Map by default (more coming
soon).
- Timestamp Comparisons instead of Intervals for Efficiency.
- Custom handlers, window duration, max requests, status code, and error message
support.
## Usage
```ts
import { RateLimiter } from "https://deno.land/x/oak_rate_limit/mod.ts";
const rateLimit = RateLimiter({
store: STORE, // Using MapStore by default.
windowMs: 1000, // Window for the requests that can be made in miliseconds.
max: (_ctx: Context) => 100, // Max requests within the predefined window.
headers: true, // Default true, it will add the headers X-RateLimit-Limit, X-RateLimit-Remaining.
message: "Too many requests, please try again later.", // Default message if rate limit reached.
statusCode: 429, // Default status code if rate limit reached.
});
app.use(await rateLimit);
```
## Configuration
`onRateLimit(opt, ctx, next)`
Define a custom method to handle when the rate limit has been reached. The
default implementation will send a 429 status code and the message defined in
the message option.
`skip(ctx)`
Define a custom method to skip/whitelist the rate limit. The default
implementation will return false.
## Liked The Project?
[](https://ko-fi.com/W7W31Z2B3)
## License
[Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0)