2022-02-15 20:30:52 +00:00
|
|
|
import { PrismaClient } from "@prisma/client";
|
|
|
|
|
2022-04-14 21:25:24 +00:00
|
|
|
import { bookingReferenceMiddleware } from "./middleware";
|
|
|
|
|
2022-02-24 01:14:37 +00:00
|
|
|
declare global {
|
2022-03-03 19:29:19 +00:00
|
|
|
var prisma: PrismaClient | undefined;
|
2022-02-24 01:14:37 +00:00
|
|
|
}
|
|
|
|
|
2022-02-15 20:30:52 +00:00
|
|
|
export const prisma =
|
|
|
|
globalThis.prisma ||
|
|
|
|
new PrismaClient({
|
2022-03-09 22:56:05 +00:00
|
|
|
// log: ["query", "error", "warn"],
|
2022-02-15 20:30:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV !== "production") {
|
|
|
|
globalThis.prisma = prisma;
|
|
|
|
}
|
2022-04-14 21:25:24 +00:00
|
|
|
// If any changed on middleware server restart is required
|
|
|
|
bookingReferenceMiddleware(prisma);
|
2022-02-15 20:30:52 +00:00
|
|
|
|
|
|
|
export default prisma;
|