mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-04-27 02:18:29 -04:00
18 lines
574 B
TypeScript
18 lines
574 B
TypeScript
import { PrismaClient } from "@prisma/client/edge";
|
|
|
|
// creating PrismaClient here prevents next.js from starting too many concurrent prisma instances and exhausting the
|
|
// number of connection pools available (especially when hot reloading from `next dev`).
|
|
// https://pris.ly/d/help/next-js-best-practices
|
|
|
|
const globalForPrisma = globalThis as unknown as {
|
|
prisma: PrismaClient | undefined;
|
|
};
|
|
|
|
export const prisma =
|
|
globalForPrisma.prisma ??
|
|
new PrismaClient({
|
|
log: ["query"],
|
|
});
|
|
|
|
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
|