volks
volks2y ago

Integrate third-party added endpoints into the router definition?

Its would be cool but not too important, so I was wondering whether or not it would be possible to have dummy router configs without any actual routers. I am using SuperTokens for my Auth and it adds several endpoints to my server (/auth/signup, /auth/login and so on), and it would be cool to somehow add these into tRPC so that I could ditch custom fetch calls.
5 Replies
Nick
Nick2y ago
You could use tRPC as a proxy to those endpoints, or you could use their SDK to integrate the functionality manually There’s no free lunch though, you’ll need to write something
volks
volks2y ago
Yeah, I was just wondering if there was some TS magic that could be done to get the types into the router and have the TRPC call the endpoints. I guess I'll leave that aside for now
Nick
Nick2y ago
If you can get TS types either by codegen or from an SDK then tying those into tRPC should be a breeze. Outputs get inferred, inputs might be a bit more effort as you’d be best off writing some Zod types for them
volks
volks2y ago
@Nick Lucas I know the Types, they're rather simplistic. how could I integrate those into the router?
Nick
Nick2y ago
Same way as writing any router/procedure really You're just writing a wrapper