import { PrismaClient } from '@prisma/client';
import { getWcagConfig } from '@wcag-ada/config';

const config = getWcagConfig();

const globalForPrisma = global as unknown as { prisma: PrismaClient };

export const prisma =
  globalForPrisma.prisma ||
  new PrismaClient({
    log: config.environment === 'development' ? ['error', 'warn'] : ['error'],
  });

if (config.environment !== 'production') globalForPrisma.prisma = prisma;