UNPKG

@quell/server

Version:

Quell is an open-source NPM package providing a light-weight caching layer implementation and cache invalidation for GraphQL responses on both the client- and server-side. Use Quell to prevent redundant client-side API requests and to minimize costly serv

16 lines 987 B
import { Request, Response, NextFunction } from "express"; import { RedisClientType } from "redis"; export interface RateLimiterConfig { ipRate: number; redisCache: RedisClientType; } /** * A redis-based IP rate limiter middleware function that limits the number of requests per second based on IP address using Redis. * @param {Request} req - Express request object, including request body with GraphQL query string. * @param {Response} res - Express response object, will carry query response to next middleware. * @param {NextFunction} next - Express next middleware function, invoked when QuellCache completes its work. * @returns {void} Passes an error to Express if no query was included in the request or if the number of requests by the current IP * exceeds the IP rate limit. */ export declare function createRateLimiter(config: RateLimiterConfig): (req: Request, res: Response, next: NextFunction) => Promise<void>; //# sourceMappingURL=rateLimiter.d.ts.map