diff --git a/lib/helpers/customPrisma.ts b/lib/helpers/customPrisma.ts index 54bb8e76e4..a30cb6bcb6 100644 --- a/lib/helpers/customPrisma.ts +++ b/lib/helpers/customPrisma.ts @@ -9,7 +9,7 @@ const LOCAL_CONSOLE_URL = process.env.NEXT_PUBLIC_CONSOLE_URL || CONSOLE_URL; export const customPrismaClient: NextMiddleware = async (req, res, next) => { const { query: { key }, - }: { query: { key?: string } } = req; + } = req; // If no custom api Id is provided, attach to request the regular cal.com prisma client. if (!key) { req.prisma = new PrismaClient(); diff --git a/lib/utils/isAdmin.ts b/lib/utils/isAdmin.ts index 9db0cb5026..9b9e6f5342 100644 --- a/lib/utils/isAdmin.ts +++ b/lib/utils/isAdmin.ts @@ -1,4 +1,4 @@ -import type { NextApiRequest } from "next/types"; +import type { NextApiRequest } from "next"; import { UserPermissionRole } from "@calcom/prisma/enums"; diff --git a/next.d.ts b/next.d.ts new file mode 100644 index 0000000000..7d5f82441a --- /dev/null +++ b/next.d.ts @@ -0,0 +1,21 @@ +import type { Session } from "next-auth"; +import type { NextApiRequest as BaseNextApiRequest } from "next/types"; + +import type { PrismaClient } from "@calcom/prisma/client"; + +export type * from "next/types"; + +export declare module "next" { + interface NextApiRequest extends BaseNextApiRequest { + session?: Session | null; + + userId: number; + method: string; + prisma: PrismaClient; + // session: { user: { id: number } }; + // query: Partial<{ [key: string]: string | string[] }>; + isAdmin: boolean; + isCustomPrisma: boolean; + pagination: { take: number; skip: number }; + } +} diff --git a/pages/api/docs.ts b/pages/api/docs.ts index 27a09c650c..fb48027c35 100644 --- a/pages/api/docs.ts +++ b/pages/api/docs.ts @@ -1,7 +1,7 @@ import modifyRes from "modify-response-middleware"; +import type { NextApiRequest, NextApiResponse } from "next"; import { use } from "next-api-middleware"; import { withSwagger } from "next-swagger-doc"; -import type { NextApiRequest, NextApiResponse } from "next/types"; import pjson from "~/package.json";