Skip to content

Framework for Rate limiting middleware #15

@shalarewicz

Description

@shalarewicz

The primary entry point for our rate limiting middleware will be a function that accepts:

  • rate limiting method
  • GraphQL Schema
  • optional TypeWeightConfig parameters and outputs Express middleware.
  • redis client

Rate Limiter options should be presented as an enum consisting of Token Bucket, Leaky Bucket, Fixed Window, Sliding Window Log and Sliding Window Counter choices.

During configuration this function should:

  • Setup a Redis Client
  • Parse the schema using the provided or default TypeWeightConfig to obtain a TypeWeightObject.
  • Configure the selected RateLimiter
  • Configure complexity analysis algorithm using the TypeWeightObject
  • Return express middleware based on the above configuration.

The middleware will need to be able to have access to the GraphQL query , a unique user identifier (such as IP) and request timestamp and will call the next middleware if the request is allowed or reject the request using a 429 status code if the rate limiter denies the request.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions