From 8a8d284113e9d4a163a49f1ab3b6422f846ff8e8 Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Fri, 6 Oct 2023 15:17:07 -0300 Subject: [PATCH] fix: API cold boot issues (#11740) --- apps/api/pages/api/slots/_get.ts | 6 +++--- apps/web/pages/api/link.ts | 6 +++--- packages/app-store/cal-ai/api/_getAdd.ts | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/api/pages/api/slots/_get.ts b/apps/api/pages/api/slots/_get.ts index a74d3ae83f..ffa3b83d74 100644 --- a/apps/api/pages/api/slots/_get.ts +++ b/apps/api/pages/api/slots/_get.ts @@ -3,7 +3,7 @@ import type { NextApiRequest, NextApiResponse } from "next"; import { HttpError } from "@calcom/lib/http-error"; import { defaultResponder } from "@calcom/lib/server"; import { createContext } from "@calcom/trpc/server/createContext"; -import { viewerRouter } from "@calcom/trpc/server/routers/viewer/_router"; +import { slotsRouter } from "@calcom/trpc/server/routers/viewer/slots/_router"; import { TRPCError } from "@trpc/server"; import { getHTTPStatusCodeFromError } from "@trpc/server/http"; @@ -11,10 +11,10 @@ import { getHTTPStatusCodeFromError } from "@trpc/server/http"; async function handler(req: NextApiRequest, res: NextApiResponse) { /** @see https://trpc.io/docs/server-side-calls */ const ctx = await createContext({ req, res }); - const caller = viewerRouter.createCaller(ctx); + const caller = slotsRouter.createCaller(ctx); try { // eslint-disable-next-line @typescript-eslint/no-explicit-any - return await caller.slots.getSchedule(req.query as any /* Let tRPC handle this */); + return await caller.getSchedule(req.query as any /* Let tRPC handle this */); } catch (cause) { if (cause instanceof TRPCError) { const statusCode = getHTTPStatusCodeFromError(cause); diff --git a/apps/web/pages/api/link.ts b/apps/web/pages/api/link.ts index a2f51f2e1e..20adeb0173 100644 --- a/apps/web/pages/api/link.ts +++ b/apps/web/pages/api/link.ts @@ -7,7 +7,7 @@ import prisma from "@calcom/prisma"; import { UserPermissionRole } from "@calcom/prisma/enums"; import { TRPCError } from "@calcom/trpc/server"; import { createContext } from "@calcom/trpc/server/createContext"; -import { viewerRouter } from "@calcom/trpc/server/routers/viewer/_router"; +import { bookingsRouter } from "@calcom/trpc/server/routers/viewer/bookings/_router"; enum DirectAction { ACCEPT = "accept", @@ -55,13 +55,13 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { try { /** @see https://trpc.io/docs/server-side-calls */ const ctx = await createContext({ req, res }, sessionGetter); - const caller = viewerRouter.createCaller({ + const caller = bookingsRouter.createCaller({ ...ctx, req, res, user: { ...user, locale: user?.locale ?? "en" }, }); - await caller.bookings.confirm({ + await caller.confirm({ bookingId: booking.id, recurringEventId: booking.recurringEventId || undefined, confirmed: action === DirectAction.ACCEPT, diff --git a/packages/app-store/cal-ai/api/_getAdd.ts b/packages/app-store/cal-ai/api/_getAdd.ts index b263e28768..9928f1a72f 100644 --- a/packages/app-store/cal-ai/api/_getAdd.ts +++ b/packages/app-store/cal-ai/api/_getAdd.ts @@ -2,7 +2,7 @@ import type { NextApiRequest, NextApiResponse } from "next"; import { defaultResponder } from "@calcom/lib/server"; import { createContext } from "@calcom/trpc/server/createContext"; -import { viewerRouter } from "@calcom/trpc/server/routers/viewer/_router"; +import { apiKeysRouter } from "@calcom/trpc/server/routers/viewer/apiKeys/_router"; import checkSession from "../../_utils/auth"; import getInstalledAppPath from "../../_utils/getInstalledAppPath"; @@ -15,9 +15,9 @@ export async function getHandler(req: NextApiRequest, res: NextApiResponse) { const appType = appConfig.type; const ctx = await createContext({ req, res }); - const caller = viewerRouter.createCaller(ctx); + const caller = apiKeysRouter.createCaller(ctx); - const apiKey = await caller.apiKeys.create({ + const apiKey = await caller.create({ note: "Cal.ai", expiresAt: null, appId: "cal-ai",