Skip to content

Add createRateLimitMiddleware middleware to create rate limit middleware quickly #566

@ozziest

Description

@ozziest

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);
};

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestnext-releaseThe feature will be released in the next releaseversion-minorMinor version changes

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions