mirror of
https://github.com/ajnart/homarr.git
synced 2026-02-05 06:09:16 +01:00
35 lines
989 B
TypeScript
35 lines
989 B
TypeScript
import type { inferRouterInputs, inferRouterOutputs } from "@trpc/server";
|
|
|
|
import { openApiDocument } from "./open-api";
|
|
import type { AppRouter } from "./root";
|
|
import { appRouter } from "./root";
|
|
import { createCallerFactory, createTRPCContext } from "./trpc";
|
|
|
|
/**
|
|
* Create a server-side caller for the tRPC API
|
|
* @example
|
|
* const trpc = createCaller(createContext);
|
|
* const res = await trpc.post.all();
|
|
* ^? Post[]
|
|
*/
|
|
const createCaller = createCallerFactory(appRouter);
|
|
|
|
/**
|
|
* Inference helpers for input types
|
|
* @example
|
|
* type PostByIdInput = RouterInputs['post']['byId']
|
|
* ^? { id: number }
|
|
**/
|
|
type RouterInputs = inferRouterInputs<AppRouter>;
|
|
|
|
/**
|
|
* Inference helpers for output types
|
|
* @example
|
|
* type AllPostsOutput = RouterOutputs['post']['all']
|
|
* ^? Post[]
|
|
**/
|
|
type RouterOutputs = inferRouterOutputs<AppRouter>;
|
|
|
|
export { createTRPCContext, appRouter, createCaller, openApiDocument };
|
|
export type { AppRouter, RouterInputs, RouterOutputs };
|