From 812ceda4a09d124d033f50003984e8214001962d Mon Sep 17 00:00:00 2001 From: Robert Soriano Date: Thu, 19 May 2022 10:54:08 -0700 Subject: [PATCH] update merging routers example --- recipes/merging-routers.md | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/recipes/merging-routers.md b/recipes/merging-routers.md index 5cb179e..5c93328 100644 --- a/recipes/merging-routers.md +++ b/recipes/merging-routers.md @@ -2,21 +2,11 @@ Writing all API-code in your code in the same file is not a great idea. It's easy to merge routers with other routers. +Define your routes: + ```ts // ~/server/trpc/routes/posts.ts export const posts = trpc.router() - .mutation('create', { - input: z.object({ - title: z.string(), - }), - resolve: ({ input }) => { - // .. - return { - id: 'xxxx', - ...input, - } - }, - }) .query('list', { resolve() { // .. @@ -45,3 +35,12 @@ export const router = trpc.router() .merge('user.', users) // prefix user procedures with "user." .merge('post.', posts) // prefix post procedures with "post." ``` + +and use it like this: + +```html + +```