From a180d053822c7208b8bc93b3151332bbb0604e55 Mon Sep 17 00:00:00 2001 From: andrzej Date: Tue, 11 Jun 2024 15:36:12 +0200 Subject: [PATCH] setup prisma client --- src/app/lib/db.mts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/app/lib/db.mts diff --git a/src/app/lib/db.mts b/src/app/lib/db.mts new file mode 100644 index 0000000..a7b5c07 --- /dev/null +++ b/src/app/lib/db.mts @@ -0,0 +1,15 @@ +import { PrismaClient } from '@prisma/client' + +const prismaClientSingleton = () => { + return new PrismaClient() +} + +declare const globalThis: { + prismaGlobal: ReturnType; +} & typeof global; + +const prisma = globalThis.prismaGlobal ?? prismaClientSingleton() + +export default prisma + +if (process.env.NODE_ENV !== 'production') globalThis.prismaGlobal = prisma