DrizzyDrake
DrizzyDrake6mo ago

Brainstorming how to convert REST api to tRPC

I have a use case where I have a url that looks similar to /stores/:store/items/:items and store could have many sub routes to it. is there any ideas on the best way to convert this into a tRPC route?
Solution:
create a stores router with different procedures, items being one of them, and then pass :store and :item as fields on your input object, so something like: ```ts // ... .input(z.object({ storeId: z.string(), itemId: z.string() }))...
Jump to solution
1 Reply
Solution
theMostCuriousHomunculus
create a stores router with different procedures, items being one of them, and then pass :store and :item as fields on your input object, so something like:
// ...
.input(z.object({ storeId: z.string(), itemId: z.string() }))
// ...
// ...
.input(z.object({ storeId: z.string(), itemId: z.string() }))
// ...
let me know if you need more details!