tRPCのRouter
code:ts
const t = initTRPC.create();
backend側のrouterを1箇所のみ定義
code:ts
const appRouter = mergeRouters(userRouter, postRouter)
export type AppRouter = typeof appRouter;
clientと共有するのはこの型だけ!
routerを親子構造にすることでネストできる
code:ts
const appRouter = router({
user: userRouter, // put procedures under "user" namespace
post: postRouter, // put procedures under "post" namespace
});
export const userRouter = router({
list: publicProcedure.query(() => {
return [];
}),
});