tRPC – Build and consume typesafe APIs without schemas or code generation
101–110 of 223 posts
Re: tRPC – Build and consume typesafe APIs without schemas or code generation
#102Earlier quoted context omitted.
Could you expand on this? You don't need it, but you certainly can prefer to use it regardless? Hoping react-server-components trpc gets solved soon
If you use Server Actions, you can just call a server function from your frontend directly, no need for middleware like tRPC https://nextjs.org/docs/app/building-your-application/data-f...
Will try out calling the database directly there, but I kinda liked how with tRPC I can add validation/auth checks etc/ will have to see how I develop my own strategy for that w server actions.
Re: tRPC – Build and consume typesafe APIs without schemas or code generation
#103Telefunc is another alternative without the boilerplate where on the frontend you can just import and execute the backend functions remotely. https://telefunc.com/
Re: tRPC – Build and consume typesafe APIs without schemas or code generation
#104I've used tRPC and Next.js for a couple of personal projects and it's been a great experience. Hard to beat on iteration speed, especially when used with a pre-configured template like Create T3 App: https://create.t3.gg/ .
Does it now work properly with Next 13 and server components?
Re: tRPC – Build and consume typesafe APIs without schemas or code generation
#105I'm currently in the process of removing tRPC from our codebase. It's been a nightmare of tight coupling. I've also found that it encourages more junior developers to not think about interfaces / data access patterns (there's a mapping from Prisma straight through to the component). It's fantastic for rapid prototyping but really paints you into a corner if you ever want to decouple the codebase.
Re: tRPC – Build and consume typesafe APIs without schemas or code generation
#106I'm currently in the process of removing tRPC from our codebase. It's been a nightmare of tight coupling. I've also found that it encourages more junior developers to not think about interfaces / data access patterns (there's a mapping from Prisma straight through to the component). It's fantastic for rapid prototyping but really paints you into a corner if you ever want to decouple the codebase.
Re: tRPC – Build and consume typesafe APIs without schemas or code generation
#107I'm currently in the process of removing tRPC from our codebase. It's been a nightmare of tight coupling. I've also found that it encourages more junior developers to not think about interfaces / data access patterns (there's a mapping from Prisma straight through to the component). It's fantastic for rapid prototyping but really paints you into a corner if you ever want to decouple the codebase.
Re: tRPC – Build and consume typesafe APIs without schemas or code generation
#108We’ve use an API style similar to tRPC at Notion, although our API predated tRPC by 4 years or so. You can build this kind of thing yourself easily using Typescript’s mapped types, by building an object type where the keys are your API names, and the values are { request, response } types. Structure your “server” bits to define each API handler as a function taking APIs[“addUser”][“request”] and returning Promise . T…
The requests and responses are inferred from the interface (published following semver) defined in Zod (including the errors that are following HTTP-like conventions: 401, 409…).
It also includes “hooks” for pre and post processing on the server side (effectively middlewares)
Re: tRPC – Build and consume typesafe APIs without schemas or code generation
#109Earlier quoted context omitted.
The embedded device the server is running on has a very weak CPU. Since I'm trying to optimize throughput this would have quite an impact. It's fine if the first few messages are slow, the speed just has to pick up after initialization is done, which is why negotiation is okay for me. So e.g. the client requesting IDs for every method on first connection would be fine, and would keep complexity down.
I imagine you could write a custom tRPC link to send the data over something like MQTT which may be better for an embedded client - there's prior art in the likes of electron-trpc, showing how tRPC could be adapted to non-HTTP transports. Not sure how that interacts with the JSON-RPC bits of the subscription protocol though, if there's no way around it then plain MQTT may be better suited to your use case.
Essentially I'd like to inject a custom respond[0] encoder and a custom parseMessage[1] decoder, and same for the client.
[0]: https://github.com/trpc/trpc/blob/main/packages/server/src/a...
[1]: https://github.com/trpc/trpc/blob/main/packages/server/src/a...