Should I create a trpc procedure for third party apis?

Should I be creating trpc procedures for calling third party apis, or should I just fetch them directly or use React Query by itself? For example, if I'm using the YouTube or Spotify search api in my app and doing nothing else with my db is it worth it to wrap this call into a procedure?
7 Replies
Neto
Neto2y ago
you can use trpc for proxying requests and avoid showing info like environment variables
Ramsay
RamsayOP2y ago
Does trpc have any special methods for proxying requests or would I just call fetch and return the results rather than calling my db like usual?
Neto
Neto2y ago
proxying in the sense of using next api route to handle that request and not showing anything that you should not in the client like a api key as example
Dosha
Dosha2y ago
@Neto i use open api plugin https://github.com/jlalmes/trpc-openapi
GitHub
GitHub - jlalmes/trpc-openapi: OpenAPI support for tRPC 🧩
OpenAPI support for tRPC 🧩. Contribute to jlalmes/trpc-openapi development by creating an account on GitHub.
Dosha
Dosha2y ago
i have a whole separate router + context for it
Ramsay
RamsayOP2y ago
What are the benefits of having a separate router and context?
Dosha
Dosha2y ago
wait, i think i misunderstood ur request, sorry .. my thing is that whenever i want some external system to call my server, i would handle it that way instead in terms of ur requirement, you can have a router that isn't hooked to the root router as a service layer, if it makes it easier for you to isolate systems but honestly calling a function and passing relevant params seems easier
Want results from more Discord servers?
Add your server