({
max,
windowMs,
}: {
max: number;
windowMs: number;
})
| 16 | import { TRPCForbiddenError } from './errors'; |
| 17 | |
| 18 | export 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 | |
| 34 | export async function createContext({ req, res }: CreateFastifyContextOptions) { |
| 35 | const cookies = (req as any).cookies as Record<string, string | undefined>; |
no test coverage detected