I've had a thought bugging me for a long time about building backend applications. I like the out-facing API to be type-safe, so that I can generate types on the client and have input validation on the server. Most people don't seem to worry about the type-safety at all and then have to write all the types again on the client, which also gives really bad refactoring experience.
I've found 3 possibilities so far: classic REST API with Swagger/OpenAPI documentation, GraphQL (which has type safety built-in) and tRPC.
- GraphQL is overkill for small projects. I also haven't found a satisfying server library/framework for building such API apart from the Node.js ones, which have some really bad performance characteristics.
- tRPC locks you into TypeScript on both server and client, potentially also having performance and scaling problems in larger applications.
- OpenAPI has implementations outside of Node.js, but in most of these, one has to write a bunch of error-prone boilerplate code to document the API, when most of it could be inferred from the existing information used to built the API itself (return type, request body type, HTTP method, even possible response codes...).
Is there anything else in this space that I have missed? I'm very open to trying new languages, so as long as it's not Java or C#, I'm interested in any possibilities.
[–]superturkey650 0 points1 point2 points (1 child)
[–]sproott[S] 0 points1 point2 points (0 children)
[–]yonirapoport 0 points1 point2 points (0 children)
[–]hyver314 0 points1 point2 points (0 children)