import { createTRPCProxyClient, httpLink } from '@trpc/client'; import type { inferRouterInputs, inferRouterOutputs } from '@trpc/server'; import type { TZippoRouter } from 'zippo-interface'; import { env } from '../env.server'; const makeClient = () => createTRPCProxyClient({ links: [ httpLink({ url: env.ZIPPO_URL, headers() { return { apiKey: env.ZIPPO_API_KEY }; }, }), ], }); let trpcClient: ReturnType | undefined; declare global { var __trpc_client: ReturnType | undefined; } if (env.NODE_ENV === 'development') { if (!global.__trpc_client) { global.__trpc_client = makeClient(); } trpcClient = global.__trpc_client; } else { trpcClient = makeClient(); } export const client = trpcClient as ReturnType; export type RouterInputs = inferRouterInputs; export type RouterOutputs = inferRouterOutputs;