MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / rateLimitMiddleware

Function rateLimitMiddleware

packages/trpc/src/trpc.ts:18–32  ·  view source on GitHub ↗
({
  max,
  windowMs,
}: {
  max: number;
  windowMs: number;
})

Source from the content-addressed store, hash-verified

16import { TRPCForbiddenError } from './errors';
17
18export const rateLimitMiddleware = ({
19 max,
20 windowMs,
21}: {
22 max: number;
23 windowMs: number;
24}) =>
25 createTrpcRedisLimiter<typeof t>({
26 fingerprint: (ctx) => defaultFingerPrint(ctx.req),
27 message: (hitInfo) =>
28 `Too many requests, please try again later. ${hitInfo}`,
29 max,
30 windowMs,
31 redisClient: getRedisCache(),
32 });
33
34export async function createContext({ req, res }: CreateFastifyContextOptions) {
35 const cookies = (req as any).cookies as Record<string, string | undefined>;

Callers 2

auth.tsFile · 0.90
organization.tsFile · 0.90

Calls 1

getRedisCacheFunction · 0.90

Tested by

no test coverage detected