From 6180c6622c88ca33d0d387a50be9036429281598 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sat, 6 Dec 2025 16:07:11 +0000 Subject: chore: add benchmarks (#2229) * chore: add benchmarks * upgrade deps * fixes * lint --- packages/benchmarks/src/trpc.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 packages/benchmarks/src/trpc.ts (limited to 'packages/benchmarks/src/trpc.ts') diff --git a/packages/benchmarks/src/trpc.ts b/packages/benchmarks/src/trpc.ts new file mode 100644 index 00000000..3a8cfe37 --- /dev/null +++ b/packages/benchmarks/src/trpc.ts @@ -0,0 +1,26 @@ +import { createTRPCClient, httpBatchLink } from "@trpc/client"; +import superjson from "superjson"; + +import type { AppRouter } from "@karakeep/trpc/routers/_app"; + +export type TrpcClient = ReturnType; + +export function getTrpcClient(apiKey?: string) { + if (!process.env.KARAKEEP_PORT) { + throw new Error("KARAKEEP_PORT is not set. Did you start the containers?"); + } + + return createTRPCClient({ + links: [ + httpBatchLink({ + transformer: superjson, + url: `http://localhost:${process.env.KARAKEEP_PORT}/api/trpc`, + headers() { + return { + authorization: apiKey ? `Bearer ${apiKey}` : undefined, + }; + }, + }), + ], + }); +} -- cgit v1.2.3-70-g09d2