From a2e2b0ed34ebaa42dc738bf72b18c08e85017955 Mon Sep 17 00:00:00 2001 From: Hariom Balhara Date: Sat, 6 May 2023 13:20:52 +0530 Subject: [PATCH] Fix broken appsRouter (#8719) --- apps/web/pages/api/trpc/appsRouter/[trpc].ts | 4 ++++ packages/trpc/react/trpc.ts | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 apps/web/pages/api/trpc/appsRouter/[trpc].ts diff --git a/apps/web/pages/api/trpc/appsRouter/[trpc].ts b/apps/web/pages/api/trpc/appsRouter/[trpc].ts new file mode 100644 index 0000000000..e7e03ae67f --- /dev/null +++ b/apps/web/pages/api/trpc/appsRouter/[trpc].ts @@ -0,0 +1,4 @@ +import { createNextApiHandler } from "@calcom/trpc/server/createNextApiHandler"; +import { appsRouter } from "@calcom/trpc/server/routers/viewer/apps/_router"; + +export default createNextApiHandler(appsRouter); diff --git a/packages/trpc/react/trpc.ts b/packages/trpc/react/trpc.ts index aa1d08b191..01339a319d 100644 --- a/packages/trpc/react/trpc.ts +++ b/packages/trpc/react/trpc.ts @@ -37,6 +37,7 @@ const ENDPOINTS = [ "viewer", "webhook", "workflows", + "appsRouter", ] as const; export type Endpoint = (typeof ENDPOINTS)[number]; @@ -51,15 +52,14 @@ const resolveEndpoint = (links: any) => { return (ctx: any) => { const parts = ctx.op.path.split("."); let endpoint; - let path = ''; + let path = ""; if (parts.length == 2) { endpoint = parts[0] as keyof typeof links; path = parts[1]; } else { endpoint = parts[1] as keyof typeof links; - path = parts.splice(2, parts.length - 2).join('.'); + path = parts.splice(2, parts.length - 2).join("."); } - return links[endpoint]({ ...ctx, op: { ...ctx.op, path } }); }; };