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.

finalize limits

Steven Teye0f8f3efdff0
diff --git a/apps/web/lib/auth/partner.ts b/apps/web/lib/auth/partner.ts
index 5e90c6da36..9d1cbb462e 100644
--- a/apps/web/lib/auth/partner.ts
+++ b/apps/web/lib/auth/partner.ts
@@ -39,7 +39,7 @@ export const RATE_LIMIT = {
interval: "1 s",
},
analyticsApi: {
- limit: 5,
+ limit: 6,
interval: "1 s",
},
} as const;
diff --git a/apps/web/lib/auth/session.ts b/apps/web/lib/auth/session.ts
index 0d43d71920..d8f881d852 100644
--- a/apps/web/lib/auth/session.ts
+++ b/apps/web/lib/auth/session.ts
@@ -71,7 +71,7 @@ export const withSession = (handler: WithSessionHandler) =>
}
const { success, limit, reset, remaining } = await ratelimit(
- 600,
+ 60,
"1 m",
).limit(apiKey);
diff --git a/apps/web/lib/auth/workspace.ts b/apps/web/lib/auth/workspace.ts
index 906afb17bc..db19aed198 100644
--- a/apps/web/lib/auth/workspace.ts
+++ b/apps/web/lib/auth/workspace.ts
@@ -9,8 +9,8 @@ import {
PermissionAction,
getPermissionsByRole,
} from "../api/rbac/permissions";
-import { throwIfNoAccess } from "../api/tokens/throw-if-no-access";
import { Scope, mapScopesToPermissions } from "../api/tokens/scopes";
+import { throwIfNoAccess } from "../api/tokens/throw-if-no-access";
import { normalizeWorkspaceId } from "../api/workspaces/workspace-id";
import { withAxiomBodyLog } from "../axiom/server";
import { getFeatureFlags } from "../edge-config";
@@ -26,7 +26,7 @@ export const RATE_LIMIT_FOR_SESSIONS = {
interval: "1 m",
},
analyticsApi: {
- limit: 10,
+ limit: 8,
interval: "1 s",
},
} as const;
@@ -235,14 +235,15 @@ export const withWorkspace = (
// Rate limit checks for API keys
let limit = 0;
- let interval: `${number} s` | `${number} m` = "1 m";
+ let interval: `${number} s` | `${number} m` = isAnalytics
+ ? "1 s"
+ : "1 m";
if (token.project?.plan) {
const planLimit = getCurrentPlan(token.project?.plan);
limit = planLimit.limits[isAnalytics ? "analyticsApi" : "api"];
- interval = isAnalytics ? "1 s" : "1 m";
} else {
- limit = 600; // default rate limit for personal API keys
+ limit = 60; // default rate limit for personal API keys
}
const { success, headers } = await rateLimitRequest({