initial commit

This commit is contained in:
Hydroxycarbamide 2024-04-14 19:13:21 +02:00
commit 48323b32b9
23 changed files with 684 additions and 0 deletions

22
src/trpc/server.ts Normal file
View file

@ -0,0 +1,22 @@
import "server-only";
import { headers } from "next/headers";
import { cache } from "react";
import { createCaller } from "~/server/api/root";
import { createTRPCContext } from "~/server/api/trpc";
/**
* This wraps the `createTRPCContext` helper and provides the required context for the tRPC API when
* handling a tRPC call from a React Server Component.
*/
const createContext = cache(() => {
const heads = new Headers(headers());
heads.set("x-trpc-source", "rsc");
return createTRPCContext({
headers: heads,
});
});
export const api = createCaller(createContext);