From 058e7238840b362135fd080045478025e31bf720 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Mon, 30 Dec 2024 16:55:49 +0000 Subject: chore: Setup and add e2e tests for the API endpoints --- packages/e2e_tests/utils/trpc.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 packages/e2e_tests/utils/trpc.ts (limited to 'packages/e2e_tests/utils/trpc.ts') diff --git a/packages/e2e_tests/utils/trpc.ts b/packages/e2e_tests/utils/trpc.ts new file mode 100644 index 00000000..7d916d93 --- /dev/null +++ b/packages/e2e_tests/utils/trpc.ts @@ -0,0 +1,20 @@ +import { createTRPCClient, httpBatchLink } from "@trpc/client"; +import superjson from "superjson"; + +import type { AppRouter } from "@hoarder/trpc/routers/_app"; + +export function getTrpcClient(apiKey?: string) { + return createTRPCClient({ + links: [ + httpBatchLink({ + transformer: superjson, + url: `http://localhost:${process.env.HOARDER_PORT}/api/trpc`, + headers() { + return { + authorization: apiKey ? `Bearer ${apiKey}` : undefined, + }; + }, + }), + ], + }); +} -- cgit v1.2.3-70-g09d2