Skip to content

50+ open-source generative AI apps you can clone, deploy, and monetize — image generators, video tools, virtual try-ons, AI SaaS templates, and platform integrations. One-click Vercel deploy on every template.

Restore: src/lib/prisma.js

Anil Chandra Naidu Matcha9ceb3e8cb30c
diff --git a/src/lib/prisma.js b/src/lib/prisma.js
new file mode 100644
index 0000000..f993c5e
--- /dev/null
+++ b/src/lib/prisma.js
@@ -0,0 +1,17 @@
+import { PrismaClient } from "@prisma/client";
+import { PrismaPg } from "@prisma/adapter-pg";
+import { Pool } from "pg";
+
+const globalForPrisma = globalThis;
+
+const pool = new Pool({ connectionString: process.env.DATABASE_URL });
+const adapter = new PrismaPg(pool);
+
+export const prisma =
+ globalForPrisma.prisma ||
+ new PrismaClient({
+ adapter,
+ log: process.env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"],
+ });
+
+if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;