tRPC alternatives for a simple public API

I have a T3 monorepo with tRPC with 100+ PRIVATE API endpoints. 1) I want to create a public API with around 10 basic read endpoints that can be used across various platforms and languages. What other options do y’all suggest? 2) Is there any way to expose both REST and GraphQL simultaneously?
No description
9 Replies
cadams
cadams14mo ago
Not sure I understand your question 100% but have you heard of trpc-openapi ? https://github.com/jlalmes/trpc-openapi Apparently it can make you use your trpc routes like normal REST endpoints.
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.
Endgame1013
Endgame101314mo ago
If you’ve only got 10 read endpoints that you want to expose, then why not just use standard REST endpoints? Regarding exposing GraphQL and REST, The Guild has a pretty neat package called GraphQL SOFA that can expose REST routes from your GraphQL schema (although I think it’s limited to just Express at the moment): https://the-guild.dev/graphql/sofa-api
GraphQL SOFA
Home – GraphQL SOFA
GraphQL SOFA Documentation
teos
teos14mo ago
I'm currently working on a small lib to build REST APIs in a similar way to tRPC. Which is a common use case I think, especially if you use tRPC already. I haven't released it yet, maybe you would be interested in trying it out ?
Endgame1013
Endgame101314mo ago
@teos that sounds dope. Would you be willing to drop a link?
teos
teos14mo ago
Sure, I need to publish it first, I'll post a link to npm here, probably tomorrow
teos
teos14mo ago
npm
@trestjs/react-query
React Query - End-to-end typesafe REST APIs, the tRPC way. Latest version: 0.0.6, last published: 2 minutes ago. Start using @trestjs/react-query in your project by running npm i @trestjs/react-query. There are no other projects in the npm registry using @trestjs/react-query.
teos
teos14mo ago
@Endgame1013 It's still a proof of concept, you're welcome to try it out. It won't replace tRPC anytime soon, but it lets you to define REST routes, and you can control searchParams, body, headers, etc, with full type safety Technically, it could become tRPC compatible, but I'm not focusing on that right now. I just want to build fast AND have a RESTful API to share with other devs/teams (not a custom protocol like tRPC) Let me now what you think, any feedback/help would be greatly appreciated 🤓 @Eddy - SolarX is this the kind of project you're looking for ?
JJ Rise
JJ Rise14mo ago
I had a very similar use case. We have a large private tRPC api for our t3 based monorepo and wanted to expose a handful of public endpoints. I ended up setting up Hono as a package and doing it that way. Could still share my db instance and was pretty smooth for the most part.
unnoq
unnoq4w ago
I made this one, less verbose - more powerful tRPC, ts-rest, Zodios alternative: https://github.com/unnoq/orpc
GitHub
GitHub - unnoq/orpc: End-to-end typesafe APIs builder, Developer-fi...
End-to-end typesafe APIs builder, Developer-first simplicity - unnoq/orpc
Want results from more Discord servers?
Add your server