if (typeof process !== 'undefined') {
    process.env.UV_THREADPOOL_SIZE = "1";
    process.env.PRISMA_MAX_THREADS = "1";
    process.env.TOKIO_WORKER_THREADS = "1";
}

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


// PrismaClient is attached to the `global` object in development to prevent
// exhausting your database connection limit.
// Learn more: https://pris.ly/d/help/next-js-best-practices

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

export const prisma =
    globalForPrisma.prisma ||
    new PrismaClient({
        log: ['query'],
    });

if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;
