mirror of
https://github.com/ArthurDanjou/website.git
synced 2026-01-19 14:31:46 +01:00
Fixing all erros
This commit is contained in:
@@ -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
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user