aboutsummaryrefslogtreecommitdiffstats
path: root/apps/cli/lib/trpc.ts
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-04-02 15:12:40 +0100
committerMohamedBassem <me@mbassem.com>2024-04-02 15:12:40 +0100
commitd4406729df2d285729ab9f2ad3301e0d726ef164 (patch)
treebfba411c289c0c0e97d760b83844de0d5dc18333 /apps/cli/lib/trpc.ts
parent79321f83293bc37d37af4b0a0b2bd324f5bafe1a (diff)
downloadkarakeep-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.ts23
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}`,
+ };
+ },
+ }),
+ ],
+ });
+}