Skip to content

Commit

Permalink
manual: fix ts issues
Browse files Browse the repository at this point in the history
  • Loading branch information
DmytroHryshyn committed Dec 1, 2023
1 parent f871166 commit fd468a3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps/web/app/_trpc/createTRPCNextLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function getArrayQueryKey(
const [arrayPath, input] = queryKeyArrayed;

if (!input && (!type || type === "any")) {
return arrayPath.length ? [arrayPath] : ([] as unknown as QueryKey);
return Array.isArray(arrayPath) && arrayPath.length !== 0 ? [arrayPath] : ([] as unknown as QueryKey);
}

return [
Expand Down
3 changes: 2 additions & 1 deletion apps/web/app/_trpc/serverClient.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { TRPCContext } from "@calcom/trpc/server/createContext";
import { appRouter } from "@calcom/trpc/server/routers/_app";

export const serverClient = appRouter.createCaller({});
export const getServerCaller = (ctx: TRPCContext) => appRouter.createCaller(ctx);
4 changes: 2 additions & 2 deletions apps/web/app/_trpc/ssgInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { headers } from "next/headers";
import superjson from "superjson";

import { CALCOM_VERSION } from "@calcom/lib/constants";
import prisma from "@calcom/prisma";
import prisma, { readonlyPrisma } from "@calcom/prisma";
import { appRouter } from "@calcom/trpc/server/routers/_app";

import { createTRPCNextLayout } from "./createTRPCNextLayout";
Expand All @@ -17,7 +17,7 @@ export async function ssgInit() {
router: appRouter,
transformer: superjson,
createContext() {
return { prisma, session: null, locale, i18n };
return { prisma, insightsDb: readonlyPrisma, session: null, locale, i18n };
},
});

Expand Down
11 changes: 9 additions & 2 deletions apps/web/app/_trpc/ssrInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import superjson from "superjson";

import { getLocale } from "@calcom/features/auth/lib/getLocale";
import { CALCOM_VERSION } from "@calcom/lib/constants";
import prisma from "@calcom/prisma";
import prisma, { readonlyPrisma } from "@calcom/prisma";
import { appRouter } from "@calcom/trpc/server/routers/_app";

import { createTRPCNextLayout } from "./createTRPCNextLayout";
Expand All @@ -24,7 +24,14 @@ export async function ssrInit(options?: { noI18nPreload: boolean }) {
router: appRouter,
transformer: superjson,
createContext() {
return { prisma, session: null, locale, i18n, req: req as unknown as GetServerSidePropsContext["req"] };
return {
prisma,
insightsDb: readonlyPrisma,
session: null,
locale,
i18n,
req: req as unknown as GetServerSidePropsContext["req"],
};
},
});

Expand Down

0 comments on commit fd468a3

Please sign in to comment.