RSocket routing definition alike tRPC
linux-china opened this issue · comments
Routing is built by RSocket by default. https://github.com/rsocket/rsocket/blob/master/Extensions/Routing.md
Is it possible to define RSocket router alike tRPC? It's really easy for client and server sides.
const helloRouter = router({
hello: t.procedure
.input(
z.object({
name: z.string(),
}),
)
.request(({input}) => `hello ${input.name}` ),
hello2: publicProcedure
.input(z.string())
.fire(({input}) => {
console.log(input);
})
});
Given the popularity of tRPC
, I've been considering if there are learnings or inspiration we could take away for APIs in rsocket-js
.
We have a similar level of support here already with the rsocket-messaging
package (example), however rsocket-messaging
does not provide the same level of interface (there is small amount of extra work required with rsocket-messaging
compared to tRPC
).
How important of a consideration is the end-to-end type safety offered by tRPC
? I think that would be valuable and interesting for rsocket-js
as well, but I'm not sure how that could be approached.