Skip to content

Scheduling infrastructure for absolutely everyone.

Fix API types, detach from main repo

Alex van Andelb7e65e31d658
diff --git a/lib/helpers/customPrisma.ts b/lib/helpers/customPrisma.ts
index 54bb8e76e41..a30cb6bcb6d 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 9db0cb5026a..9b9e6f53425 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 00000000000..7d5f82441a9
--- /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 27a09c650c0..fb48027c358 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";