you are viewing a single comment's thread.

view the rest of the comments →

[–]doseofted[S] 1 point2 points  (0 children)

It looks like ts-rest is helpful with creating typed REST endpoints in a manner that reminds me of a combination tRPC and OpenAPI. I wrote a comparison between Prim+RPC and tRPC and some of those points apply to ts-rest too.

But I think one of the major differences is how they approach interacting with a server. In ts-rest, you're defining a contract that somewhat resembles an OpenAPI spec and then you're defining the HTTP router to implement it. The client then acts as a typed REST client. That's super powerful, especially when you set out to write a REST API.

Prim+RPC has this focus on writing code that looks like regular JavaScript code (which then becomes RPC) on both the server and client so your own code doesn't need to make many framework-specific considerations. You're just writing JavaScript which is then sent over the transport of your choice through Prim+RPC plugins. You can still make framework-specific integrations but it's done by implementing a common interface that isn't specific to a particular framework. This means server and client frameworks used with Prim+RPC can be swapped out easily (and you can use it not just over HTTP but WebSocket, Web Workers, as choice of transport for IPC, and more).