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.

separate files

Steven Tey432ab8cc2457
diff --git a/apps/web/lib/prisma.ts b/apps/web/lib/prisma/edge.ts
similarity index 81%
rename from apps/web/lib/prisma.ts
rename to apps/web/lib/prisma/edge.ts
index 45d76dfffb..08185a2912 100644
--- a/apps/web/lib/prisma.ts
+++ b/apps/web/lib/prisma/edge.ts
@@ -3,5 +3,9 @@ import { PrismaPlanetScale } from "@prisma/adapter-planetscale";
import { PrismaClient } from "@prisma/client";
const client = new Client({ url: process.env.DATABASE_URL });
+
const adapter = new PrismaPlanetScale(client);
-export const prisma = new PrismaClient({ adapter });
+
+export const prismaEdge = new PrismaClient({
+ adapter,
+});
diff --git a/apps/web/lib/prisma/index.ts b/apps/web/lib/prisma/index.ts
new file mode 100644
index 0000000000..8ba8a7c680
--- /dev/null
+++ b/apps/web/lib/prisma/index.ts
@@ -0,0 +1,10 @@
+import { PrismaClient } from "@prisma/client";
+
+// serverless prisma
+export const prisma = global.prisma || new PrismaClient();
+
+declare global {
+ var prisma: PrismaClient | undefined;
+}
+
+if (process.env.NODE_ENV === "development") global.prisma = prisma;