DrizzyDrakeD
tRPC2y ago
2 replies
DrizzyDrake

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:

  // ...
  .input(z.object({ storeId: z.string(), itemId: z.string() }))
  // ...


let me know if you need more details!
Was this page helpful?