first commit

This commit is contained in:
AyrisAI
2026-07-23 16:55:44 +03:00
commit bd543c3bda
61 changed files with 17313 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
import { Pool } from 'pg';
import { PrismaPg } from '@prisma/adapter-pg';
import { PrismaClient } from '@prisma/client';
const connectionString =
process.env.DATABASE_URL ||
'postgres://postgres:mBTWE2cDKGExtpktguD3HPe8y9Xr9kWFYdxV4WHQKISLLGoBAS4UdtfSCfXwvPpq@65.109.236.58:37298/postgres';
const pool = new Pool({ connectionString });
const adapter = new PrismaPg(pool);
const globalForPrisma = globalThis as unknown as {
prisma: PrismaClient | undefined;
};
function getPrismaClient(): PrismaClient {
if (process.env.NODE_ENV !== 'production' && globalForPrisma.prisma) {
// Check if newly added models (e.g. category) exist on cached client
if ((globalForPrisma.prisma as any).category) {
return globalForPrisma.prisma;
}
}
const client = new PrismaClient({ adapter });
if (process.env.NODE_ENV !== 'production') {
globalForPrisma.prisma = client;
}
return client;
}
export const db = getPrismaClient();