| import { PrismaClient } from "@/generated/prisma"; |
| import { PrismaPg } from "@prisma/adapter-pg"; |
| import { Pool } from "pg"; |
|
|
| const pool = new Pool({ |
| connectionString: process.env.DATABASE_URL, |
| ssl: { rejectUnauthorized: false }, |
| }); |
|
|
| const adapter = new PrismaPg(pool); |
|
|
| const globalForPrisma = globalThis as unknown as { |
| prisma: InstanceType<typeof PrismaClient> | undefined; |
| }; |
|
|
| export const prisma = |
| globalForPrisma.prisma ?? new PrismaClient({ adapter }); |
|
|
| if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma; |