mirror of
https://github.com/spliit-app/spliit.git
synced 2026-02-14 19:46:12 +01:00
22 lines
509 B
TypeScript
22 lines
509 B
TypeScript
import { PrismaClient } from '@prisma/client'
|
|
|
|
declare const global: Global & { prisma?: PrismaClient }
|
|
|
|
export let p: PrismaClient = undefined as unknown as PrismaClient
|
|
|
|
if (typeof window === 'undefined') {
|
|
// await delay(1000)
|
|
if (process.env['NODE_ENV'] === 'production') {
|
|
p = new PrismaClient()
|
|
} else {
|
|
if (!global.prisma) {
|
|
global.prisma = new PrismaClient({
|
|
// log: [{ emit: 'stdout', level: 'query' }],
|
|
})
|
|
}
|
|
p = global.prisma
|
|
}
|
|
}
|
|
|
|
export const prisma = p
|