POSTERAPP_V1/lib/prisma.ts

25 lines
570 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { PrismaClient } from '@prisma/client'
const globalForPrisma = globalThis as unknown as {
prisma: PrismaClient | undefined
}
export const prisma =
globalForPrisma.prisma ??
new PrismaClient({
log: ['query', 'error', 'warn'],
errorFormat: 'pretty',
})
if (process.env.NODE_ENV !== 'production') {
globalForPrisma.prisma = prisma
}
// Veritabanı bağlantısını test et
prisma.$connect()
.then(() => {
console.log('Database connection successful')
})
.catch((error) => {
console.error('Database connection error:', error)
})