feTS icon indicating copy to clipboard operation
feTS copied to clipboard

Implement Router Inheritance/Merging (Nested Router)

Open ardatan opened this issue 2 years ago • 6 comments

ardatan avatar Aug 06 '23 15:08 ardatan

Based on the issue title, I'm guessing the goal is to be able to combine multiple routers, where you can have a router for each object. tRPC has this concept, and it's very useful when it comes to structuring code https://trpc.io/docs/server/merging-routers

m-abdelwahab avatar Aug 07 '23 04:08 m-abdelwahab

Related discussions:

  • https://github.com/ardatan/feTS/discussions/384

m-abdelwahab avatar Aug 07 '23 05:08 m-abdelwahab

Thumbs up! feTS is great, but lack of a way to split routes is a real bummer.

One way I was able to partially workaround this is by extracting router's route method into standalone createRoute function, which is basically just a type helper that returns the route definition as it was passed in. This allows me to split routes into separate files and then just compose them with createRouter.route(routeA).route(routeB). Such little feature already goes a long way towards manageable code organization.

dodas avatar Nov 11 '23 14:11 dodas

I think we should consider having a similar API as trpc: https://trpc.io/docs/server/merging-routers (as proposed in the related discussion)

beerose avatar Nov 15 '23 10:11 beerose

@dodas Hey! I would love to see an example for this, could you please share one? I'm not 100% getting it 😅

m4rvr avatar Dec 08 '23 21:12 m4rvr

Really interested as well.

belgattitude avatar Jun 10 '24 09:06 belgattitude