db connect

This commit is contained in:
2026-04-17 11:16:00 +03:00
parent b675fff437
commit 5a48605c35
25 changed files with 2607 additions and 298 deletions

20
lib/prisma.ts Normal file
View File

@@ -0,0 +1,20 @@
import { Pool } from 'pg';
import { PrismaPg } from '@prisma/adapter-pg';
import { PrismaClient } from '@prisma/client';
const globalForPrisma = global as unknown as { prisma: PrismaClient };
// Robustly get connection string with fallback
const connectionString = process.env.DATABASE_URL || "postgres://postgres:P9cIY8Ji1iSXOCRs9q6WbOo5xeXCdzyQjYoQ511Zmq1RY8WHLU9YKBGyjDpJ02sa@65.109.236.58:6482/postgres";
const pool = new Pool({ connectionString });
const adapter = new PrismaPg(pool);
export const prisma =
globalForPrisma.prisma ||
new PrismaClient({
adapter,
log: ['query'],
});
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;