I am making use of API endpoint routes in my application. In these endpoints http requests about the data are processed by the backend with the help of a PRISMA ORM.
However, i have to use something else for the frontend and started to write typescript types that resemble my backend types. This is very counterintuitive coming from programming languages like haskell or other typed languages.
It seems the endpoint sits in the middle and is a source of all kinds of incompatibilities that might arise in the future. Because now I have 3 points of failure, the endpoint, the API and frontend typescript types (that are not even compiled and available at runtime.)
Is there a more type-safe way to fix the endpoint-in-the-middle-problem?
I've looked at several obscure fullstack projects such as Urweb and the less obscure Django but they lack an expressive templating language such as in Svelte or Vue. Are there other ways to make automatic type safe api endpoint code?