Fix API types, detach from main repo

This commit is contained in:
Alex van Andel 2023-05-19 19:38:19 +02:00
parent ff69481cb9
commit b7e65e31d6
4 changed files with 24 additions and 3 deletions

View File

@ -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();

View File

@ -1,4 +1,4 @@
import type { NextApiRequest } from "next/types";
import type { NextApiRequest } from "next";
import { UserPermissionRole } from "@calcom/prisma/enums";

21
next.d.ts vendored Normal file
View File

@ -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 };
}
}

View File

@ -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";