Chika f85373689a add trpc server
get calculation values types from zod schema
add loadKP reaction
get base agents data from kp
2022-11-02 13:18:33 +03:00

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,
});