fix(prisma): don't declare prisma as a global object and explicitly import it (#11839)

pull/11826/head^2
Daniel Roe 2023-10-11 23:53:54 +01:00 committed by GitHub
parent 47bb3000f6
commit 833fe7c7b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 7 deletions

View File

@ -2,6 +2,7 @@ import { expect } from "@playwright/test";
import { randomBytes } from "crypto";
import { WEBAPP_URL } from "@calcom/lib/constants";
import { prisma } from "@calcom/prisma";
import { generateSecret } from "@calcom/trpc/server/routers/viewer/oAuth/addClient.handler";
import { test } from "./lib/fixtures";

View File

@ -7,6 +7,7 @@ import { getLocation } from "@calcom/lib/CalEventParser";
import { WEBAPP_URL } from "@calcom/lib/constants";
import { HttpError } from "@calcom/lib/http-error";
import logger from "@calcom/lib/logger";
import { prisma } from "@calcom/prisma";
import type {
Calendar,
CalendarEvent,

View File

@ -4,11 +4,6 @@ import { withAccelerate } from "@prisma/extension-accelerate";
import { bookingReferenceMiddleware } from "./middleware";
declare global {
// eslint-disable-next-line no-var
var prisma: typeof prismaWithClientExtensions;
}
const prismaOptions: Prisma.PrismaClientOptions = {};
if (!!process.env.NEXT_PUBLIC_DEBUG) prismaOptions.log = ["query", "error", "warn"];
@ -57,10 +52,11 @@ const prismaWithClientExtensions = prismaWithoutClientExtensions
// const prismaWithClientExtensions = prismaWithoutClientExtensions;
export const prisma = (globalThis.prisma as typeof prismaWithClientExtensions) || prismaWithClientExtensions;
export const prisma =
((globalThis as any).prisma as typeof prismaWithClientExtensions) || prismaWithClientExtensions;
if (process.env.NODE_ENV !== "production") {
globalThis.prisma = prisma;
(globalThis as any).prisma = prisma;
}
export type PrismaClient = typeof prismaWithClientExtensions;