Motivation
Developers should be able to create rate-limit middleware quickly, by passing some configuration. Currently, Axe API supports one general middleware across the API. But developers might add different rate limit middlewares for different user types.
Usage
import { createRateLimitMiddleware } from "axe-api"
const rateLimitter = (req: IncomingMessage, res: ServerResponse, next: any) =>
createRateLimitMiddleware(req, res, next, "user-identifier", {
maxRequests: 2,
windowInSeconds: 10,
});
const onBeforeInit = async (app: App) => {
app.use(rateLimitter);
};
Motivation
Developers should be able to create rate-limit middleware quickly, by passing some configuration. Currently, Axe API supports one general middleware across the API. But developers might add different rate limit middlewares for different user types.
Usage