diff options
Diffstat (limited to 'packages/e2e_tests/utils/trpc.ts')
| -rw-r--r-- | packages/e2e_tests/utils/trpc.ts | 20 |
1 files changed, 20 insertions, 0 deletions
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<AppRouter>({ + links: [ + httpBatchLink({ + transformer: superjson, + url: `http://localhost:${process.env.HOARDER_PORT}/api/trpc`, + headers() { + return { + authorization: apiKey ? `Bearer ${apiKey}` : undefined, + }; + }, + }), + ], + }); +} |
