Refactor database access by introducing prisma.lambda.service for centralized PrismaClient usage across modules. Update imports in various handlers and services to utilize the new service, ensuring consistent database interactions and improved maintainability.

This commit is contained in:
2025-12-08 11:23:58 +05:30
parent 747566497c
commit 9abadba8f5
64 changed files with 179 additions and 220 deletions

View File

@@ -0,0 +1,22 @@
import { PrismaClient } from '@prisma/client';
import { PrismaPg } from '@prisma/adapter-pg';
const adapter = new PrismaPg({
connectionString: process.env.DATABASE_URL!,
});
let prisma: PrismaClient;
if (!(global as any).prisma) {
(global as any).prisma = new PrismaClient({
adapter,
log:
process.env.NODE_ENV === 'dev'
? ['query', 'info', 'warn', 'error']
: ['error'],
});
}
prisma = (global as any).prisma;
export const prismaClient = prisma;