profileShare

rasmusjy / roundtable

Read-only snapshot

No repository description.

main default branch 181 files Expires Sep 13, 2026, 9:06 AM
client.ts 550 bytes
1 /**
2 * Prisma client singleton.
3 *
4 * Next.js hot-reload in dev would otherwise open a new pool on every reload and
5 * exhaust Postgres connections; caching on `globalThis` avoids that.
6 */
7 import { PrismaClient } from '@prisma/client';
8
9 const globalForPrisma = globalThis as unknown as { prisma?: PrismaClient };
10
11 export const prisma =
12 globalForPrisma.prisma ??
13 new PrismaClient({
14 log: process.env.NODE_ENV === 'development' ? ['warn', 'error'] : ['error'],
15 });
16
17 if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;
18