import { PrismaClient } from '@prisma/client';
import { env } from './env';

const globalForPrisma = globalThis as unknown as { __nexumiPrisma?: PrismaClient };

export const prisma: PrismaClient = globalForPrisma.__nexumiPrisma ?? new PrismaClient();

if (env.NODE_ENV !== 'production') {
  globalForPrisma.__nexumiPrisma = prisma;
}
