25 lines
570 B
TypeScript
25 lines
570 B
TypeScript
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)
|
||
})
|