From 3352a3ea393849550573deff8d774ba6bf149471 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Wed, 24 Apr 2024 11:37:35 +0100 Subject: build(cli): Prepare for publishing CLI to npm --- apps/cli/lib/globals.ts | 17 ----------------- apps/cli/lib/trpc.ts | 23 ----------------------- 2 files changed, 40 deletions(-) delete mode 100644 apps/cli/lib/globals.ts delete mode 100644 apps/cli/lib/trpc.ts (limited to 'apps/cli/lib') diff --git a/apps/cli/lib/globals.ts b/apps/cli/lib/globals.ts deleted file mode 100644 index 771136da..00000000 --- a/apps/cli/lib/globals.ts +++ /dev/null @@ -1,17 +0,0 @@ -export interface GlobalOptions { - apiKey: string; - serverAddr: string; -} - -export let globalOpts: GlobalOptions | undefined = undefined; - -export function setGlobalOptions(opts: GlobalOptions) { - globalOpts = opts; -} - -export function getGlobalOptions() { - if (!globalOpts) { - throw new Error("Global options are not initalized yet"); - } - return globalOpts; -} diff --git a/apps/cli/lib/trpc.ts b/apps/cli/lib/trpc.ts deleted file mode 100644 index 6f0dccfe..00000000 --- a/apps/cli/lib/trpc.ts +++ /dev/null @@ -1,23 +0,0 @@ -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