The configuration options for rate limiting.
A middleware function that limits the number of requests from a client IP.
Example usage:
import { start, router, text, rateLimitMiddleware } from "@pulsar-http/core";
const routes = [
router.get("/api/users", async () => text("User List")),
];
const middlewares = [
rateLimitMiddleware({
windowMs: 60000, // 1 minute
maxRequests: 10,
}),
]
start({ routes, middlewares });
In this example, if a client IP makes more than 10 requests within a 1-minute window, subsequent requests will receive a 429 response until the window resets.
Middleware to enforce rate limiting based on client IP.