forked from nathydre21/nepa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprismaClient.ts
More file actions
25 lines (22 loc) · 779 Bytes
/
prismaClient.ts
File metadata and controls
25 lines (22 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Prisma Client singleton instance
let prisma: any;
try {
const { PrismaClient } = require('@prisma/client');
if (process.env.NODE_ENV === 'production') {
prisma = new PrismaClient();
} else {
if (!(global as any).prisma) {
(global as any).prisma = new PrismaClient();
}
prisma = (global as any).prisma;
}
} catch (err) {
// Fallback if Prisma is not properly initialized
prisma = {
webhook: { create: () => {}, findUnique: () => {}, delete: () => {}, findMany: () => [] },
webhookEvent: { create: () => {}, findMany: () => [], findUnique: () => {}, updateMany: () => {} },
webhookAttempt: { create: () => {}, findMany: () => [] },
webhookLog: { create: () => {}, findMany: () => [] },
} as any;
}
export default prisma;