cal.pub0.org/packages/prisma/index.ts

25 lines
655 B
TypeScript

import { Prisma, PrismaClient } from "@prisma/client";
import { bookingReferenceMiddleware } from "./middleware";
declare global {
// eslint-disable-next-line no-var
var prisma: PrismaClient | undefined;
}
const prismaOptions: Prisma.PrismaClientOptions = {};
if (!!process.env.NEXT_PUBLIC_DEBUG) prismaOptions.log = ["query", "error", "warn"];
export const prisma = globalThis.prisma || new PrismaClient(prismaOptions);
if (process.env.NODE_ENV !== "production") {
globalThis.prisma = prisma;
}
// If any changed on middleware server restart is required
bookingReferenceMiddleware(prisma);
export default prisma;
export * from "./selects";