get calculation values types from zod schema add loadKP reaction get base agents data from kp
36 lines
758 B
TypeScript
36 lines
758 B
TypeScript
import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
|
|
import { createTRPCNext } from '@trpc/next';
|
|
import SuperJSON from 'superjson';
|
|
import type { AppRouter } from './routers';
|
|
|
|
function getBaseUrl() {
|
|
if (typeof window !== 'undefined') {
|
|
return '';
|
|
}
|
|
|
|
return `http://localhost:${process.env.PORT ?? 3000}`;
|
|
}
|
|
|
|
export const trpcClient = createTRPCNext<AppRouter>({
|
|
config() {
|
|
return {
|
|
links: [
|
|
httpBatchLink({
|
|
url: `${getBaseUrl()}/api/trpc`,
|
|
}),
|
|
],
|
|
transformer: SuperJSON,
|
|
};
|
|
},
|
|
ssr: true,
|
|
});
|
|
|
|
export const trpcPureClient = createTRPCProxyClient<AppRouter>({
|
|
links: [
|
|
httpBatchLink({
|
|
url: `${getBaseUrl()}/api/trpc`,
|
|
}),
|
|
],
|
|
transformer: SuperJSON,
|
|
});
|