Skip to main content
Deno 2 is finally here 🎉️
Learn more

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

  • Support for stores such as Map, Redis, Memcached, etc. (Only Map is implemented for now)

Installation

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: 10, // 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(rateLimit);

Liked The Project?

ko-fi

License

Apache License 2.0