From d4406729df2d285729ab9f2ad3301e0d726ef164 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Tue, 2 Apr 2024 15:12:40 +0100 Subject: featuer: Introduce a new CLI for mass manipulation of bookmarks --- apps/cli/lib/trpc.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 apps/cli/lib/trpc.ts (limited to 'apps/cli/lib/trpc.ts') 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({ + links: [ + httpBatchLink({ + url: `${globals.serverAddr}/api/trpc`, + transformer: superjson, + headers() { + return { + authorization: `Bearer ${globals.apiKey}`, + }; + }, + }), + ], + }); +} -- cgit v1.2.3-70-g09d2