is trpc good for rest apis?
Is trpc good for making rest apis? cause i feel like api/trpc/posts.getLatest isnt that compeling of a url vs api/posts/latest. is their a way to change trpc to do something like api/posts/latest? or am i fundamentaliy looking at trpc wrong?
6 Replies
no
trpc is the "best" way to make client calls from specific backends
Alright I think I get it now thanks
There's an extension for OpenAPI
https://github.com/jlalmes/trpc-openapi
I don't know if the project is still actively maintained, but I used it about a year ago and it seemed to do the job well.
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.
trpc-openapi is unmaintained iirc. and either way you get none of the value of trpc if it's being consumed by non trpc clients.
a lot of frameworks have nice openapi integrations now, for example here's hono https://hono.dev/examples/zod-openapi
Zod OpenAPI - Hono
Web framework built on Web Standards for Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Node.js, and others. Fast, but not only fast.
Yes, that true.
For my use case, I just needed to expose 4 endpoints in a project built with trpc so I opted for trpc-openapi