Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

How to safely make Typescript work with a custom backend API

$
0
0

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?


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>