This commit is contained in:
Marcelo
2026-02-17 00:07:00 +00:00
parent b7a86a2d1c
commit be4ca2ed78
92 changed files with 6850 additions and 1188 deletions

24
lib/prisma.ts Executable file
View File

@@ -0,0 +1,24 @@
import { Pool } from 'pg'
import { PrismaPg } from '@prisma/adapter-pg'
import { PrismaClient } from '@prisma/client'
// Use the POOLER URL (6543) for the app to handle high traffic
const connectionString = process.env.DATABASE_URL
const createPrismaClient = () => {
// 1. Create the Pool
const pool = new Pool({ connectionString })
// 2. Create the Adapter
const adapter = new PrismaPg(pool)
// 3. Init the Client
return new PrismaClient({ adapter })
}
// Prevent multiple instances during development hot-reloading
declare global {
var prisma: ReturnType<typeof createPrismaClient> | undefined
}
export const db = globalThis.prisma || createPrismaClient()
if (process.env.NODE_ENV !== 'production') globalThis.prisma = db