diff options
| author | MohamedBassem <me@mbassem.com> | 2024-04-02 15:12:40 +0100 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-04-02 15:12:40 +0100 |
| commit | d4406729df2d285729ab9f2ad3301e0d726ef164 (patch) | |
| tree | bfba411c289c0c0e97d760b83844de0d5dc18333 /apps/cli/lib/trpc.ts | |
| parent | 79321f83293bc37d37af4b0a0b2bd324f5bafe1a (diff) | |
| download | karakeep-d4406729df2d285729ab9f2ad3301e0d726ef164.tar.zst | |
featuer: Introduce a new CLI for mass manipulation of bookmarks
Diffstat (limited to 'apps/cli/lib/trpc.ts')
| -rw-r--r-- | apps/cli/lib/trpc.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/apps/cli/lib/trpc.ts b/apps/cli/lib/trpc.ts new file mode 100644 index 00000000..6f0dccfe --- /dev/null +++ b/apps/cli/lib/trpc.ts @@ -0,0 +1,23 @@ +import { createTRPCClient, httpBatchLink } from "@trpc/client"; +import superjson from "superjson"; + +import type { AppRouter } from "@hoarder/trpc/routers/_app"; + +import { getGlobalOptions } from "./globals"; + +export function getAPIClient() { + const globals = getGlobalOptions(); + return createTRPCClient<AppRouter>({ + links: [ + httpBatchLink({ + url: `${globals.serverAddr}/api/trpc`, + transformer: superjson, + headers() { + return { + authorization: `Bearer ${globals.apiKey}`, + }; + }, + }), + ], + }); +} |
