Fixing all erros

This commit is contained in:
2023-09-03 19:53:50 +02:00
parent 4e09b604d3
commit 3cb5c2dcf8
8 changed files with 10358 additions and 21 deletions

View File

@@ -1,12 +0,0 @@
import process from 'node:process'
import { PrismaClient } from '@prisma/client/edge'
const globalForPrisma = globalThis as unknown as { prisma: PrismaClient }
export const prisma = globalForPrisma.prisma
|| new PrismaClient({
log: process.env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
})
if (process.env.NODE_ENV !== 'production')
globalForPrisma.prisma = prisma

View File

@@ -1,8 +1,16 @@
import type { inferAsyncReturnType } from '@trpc/server'
import type { H3Event } from 'h3'
import { prisma } from '../prisma'
import { PrismaClient } from '@prisma/client'
let prisma: PrismaClient | undefined
export function createContext(_event: H3Event) {
if (!prisma) {
prisma = new PrismaClient({
log: process.env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
})
}
return {
prisma,
}