Refactor Prisma client usage and enhance service integration for improved connection management
This commit is contained in:
@@ -1,22 +1,5 @@
|
||||
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;
|
||||
// Re-export the singleton prisma client for Lambda handlers
|
||||
// This ensures all Lambda functions use the same cached connection
|
||||
import { prisma } from './prisma.client';
|
||||
|
||||
export const prismaClient = prisma;
|
||||
Reference in New Issue
Block a user