-
Hi! Thanks for creating such awesome library for Typescript 🙏 I have an backend API where I need to have 20 or more endpoints in a single server. I'm able to define the endpoints just fine, using a couple of const api = Api.make().pipe(Api.addGroup(apiGroup1), Api.addGroup(apiGroup2));
RouterBuilder.make(api).pipe(
RouterBuilder.handle("group1-endpoint1", request => /* handler logic */),
// ... other 18 handlers
RouterBuilder.handle("group2-endpoint10", request => /* handler logic */),
RouterBuilder.build
) I'm unable to do so because Ideally I would just define handlers for each const routerBuilder1 = RouterBuilder.make(apiGroup1).pipe(
RouterBuilder.handle("group1-endpoint1", request => /* handler logic */),
// ...
)
const routerBuilder2 = RouterBuilder.make(apiGroup2).pipe(
RouterBuilder.handle("group2-endpoint1", request => /* handler logic */),
// ... 10 or so handlers
)
RouterBuilder.combine(routerBuilder1, routerBuilder2).pipe(RouterBuilder.build) // Something like this to compose all builders together How could I circumvent this limitation and create handlers for over 20 routes? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hey, good point 👍. I added const app = RouterBuilder.merge(routerBuilder1, routerBuilder2).pipe(RouterBuilder.build)
// or
const app = routerBuilder1.pipe(
RouterBuilder.merge(routerBuilder2),
RouterBuilder.merge(routerBuilder3),
...,
RouterBuilder.build
) |
Beta Was this translation helpful? Give feedback.
-
Awesome, thanks a lot! 🚀 |
Beta Was this translation helpful? Give feedback.
Hey, good point 👍. I added
RouterBuilder.merge
.You can use check the tests or docs