Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

rate limit

Kiran K55803d82e104
diff --git a/apps/web/lib/auth/partner.ts b/apps/web/lib/auth/partner.ts
index 59867a652c..fdaeb277a8 100644
--- a/apps/web/lib/auth/partner.ts
+++ b/apps/web/lib/auth/partner.ts
@@ -3,6 +3,7 @@ import { PartnerProps } from "@/lib/types";
import { prisma } from "@dub/prisma";
import { getSearchParams } from "@dub/utils";
import { AxiomRequest, withAxiom } from "next-axiom";
+import { ratelimit } from "../upstash";
import { Session, getSession } from "./utils";
interface WithPartnerProfileHandler {
@@ -61,8 +62,6 @@ export const withPartnerProfile = (
},
});
- console.log("partner-found", partner);
-
// partner profile doesn't exist
if (!partner || !partner.users) {
throw new DubApiError({
@@ -79,6 +78,16 @@ export const withPartnerProfile = (
});
}
+ // rate limit
+ const { success } = await ratelimit(600, "1 m").limit(partner.id);
+
+ if (!success) {
+ throw new DubApiError({
+ code: "rate_limit_exceeded",
+ message: "Too many requests.",
+ });
+ }
+
return await handler({
req,
params,