🎨 Move short circuit

This commit is contained in:
Luke Vella 2024-09-08 22:09:45 +01:00
parent 19f6196201
commit 4cdc409b8d
No known key found for this signature in database
GPG key ID: 469CAD687F0D784C

View file

@ -76,15 +76,15 @@ export const privateProcedure = t.procedure.use(
);
export const rateLimitMiddleware = middleware(async ({ ctx, next }) => {
if (!process.env.KV_REST_API_URL) {
return next();
}
const ratelimit = new Ratelimit({
redis: kv,
limiter: Ratelimit.slidingWindow(5, "1 m"),
});
if (!process.env.KV_REST_API_URL) {
return next();
}
const clientIp = requestIp.getClientIp(ctx.req);
if (!clientIp) {