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.

Create set-workspace-cache.ts

Kiran K78f0ac1e3e4c
diff --git a/apps/web/scripts/set-workspace-cache.ts b/apps/web/scripts/set-workspace-cache.ts
new file mode 100644
index 0000000000..2997f04fc7
--- /dev/null
+++ b/apps/web/scripts/set-workspace-cache.ts
@@ -0,0 +1,33 @@
+import "dotenv-flow/config";
+import { workspaceCache } from "@/lib/api/workspace-cache";
+import { prisma } from "@dub/prisma";
+
+async function main() {
+ const workspaces = await prisma.project.findMany({
+ where: {
+ allowedHostnames: {
+ // @ts-ignore
+ not: null,
+ },
+ },
+ select: {
+ id: true,
+ allowedHostnames: true,
+ },
+ });
+
+ console.log(`Setting cache for ${workspaces.length} workspaces`);
+
+ await Promise.all(
+ workspaces.map((workspace) => {
+ workspaceCache.set({
+ id: workspace.id,
+ data: {
+ allowedHostnames: workspace.allowedHostnames as string[],
+ },
+ });
+ }),
+ );
+}
+
+main();