diff options
| author | Mohamed Bassem <me@mbassem.com> | 2025-12-06 16:07:11 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-06 16:07:11 +0000 |
| commit | 6180c6622c88ca33d0d387a50be9036429281598 (patch) | |
| tree | 1df3e4143a489ada2f542896bf2f2ae392a727ca /packages/benchmarks/src/trpc.ts | |
| parent | de98873a06a25084eb2d3bcabda158f23c081672 (diff) | |
| download | karakeep-6180c6622c88ca33d0d387a50be9036429281598.tar.zst | |
chore: add benchmarks (#2229)
* chore: add benchmarks
* upgrade deps
* fixes
* lint
Diffstat (limited to 'packages/benchmarks/src/trpc.ts')
| -rw-r--r-- | packages/benchmarks/src/trpc.ts | 26 |
1 files changed, 26 insertions, 0 deletions
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<typeof getTrpcClient>; + +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<AppRouter>({ + links: [ + httpBatchLink({ + transformer: superjson, + url: `http://localhost:${process.env.KARAKEEP_PORT}/api/trpc`, + headers() { + return { + authorization: apiKey ? `Bearer ${apiKey}` : undefined, + }; + }, + }), + ], + }); +} |
