ardatan/feTS

Implement Router Inheritance/Merging (Nested Router)

ardatan opened this issue · 6 comments

Implement Router Inheritance/Merging (Nested Router)

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

Related discussions:

dodas commented

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.

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

m4rvr commented

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