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.

add script for revise the rate limit

Kiran K8709d5a4ae5b
diff --git a/apps/web/scripts/update-api-rate-limits.ts b/apps/web/scripts/update-api-rate-limits.ts
new file mode 100644
index 0000000000..152c3d0f56
--- /dev/null
+++ b/apps/web/scripts/update-api-rate-limits.ts
@@ -0,0 +1,33 @@
+import { prisma } from "@/lib/prisma";
+import { getCurrentPlan } from "@dub/utils";
+import "dotenv-flow/config";
+
+async function main() {
+ const tokens = await prisma.restrictedToken.findMany({
+ select: {
+ id: true,
+ project: {
+ select: {
+ plan: true,
+ },
+ },
+ },
+ take: 500
+ });
+
+
+ for (const token of tokens) {
+ const plan = getCurrentPlan(token.project.plan);
+
+ await prisma.restrictedToken.update({
+ where: {
+ id: token.id,
+ },
+ data: {
+ rateLimit: plan.limits.api,
+ },
+ });
+ }
+}
+
+main();