Skip to content

Commit

Permalink
🎨 Move short circuit
Browse files Browse the repository at this point in the history
  • Loading branch information
lukevella committed Sep 8, 2024
1 parent 19f6196 commit 4cdc409
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions apps/web/src/trpc/trpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4cdc409

Please sign in to comment.