3 ms·
How to Speed Up Full-Stack Development by Not Building APIs
- subradios 4y agoHow is the actual communication handled? I've invoked similar setups by eg. creating an entirely separate types library that is universal - but how do you get around data interchange being a necessary and defined part of the system? (Mostly, that at some point real clients are calling real APIs over a network)
- petermasking 4y agoHi subradios, thanks for asking. Jitar is a layer on top on node that intercepts all application imports. So when the front-end imports a back-end function, Jitar will provide a remote implementation of the function that calls the function on back-end (like a dependency injector). Currently we only support HTTP, but support for gRPC is planned. All data is getting serialized automatically when transferred. Even (complex) class instances are supported with private fields. For this we add the source location of the class to the object (in the background), so that the receiving end can load the class and reconstruct the instance. This way almost any object can be passed around. The only thing is that you need to treat these objects as immutable in order to safely work with them. Hope this answers your questions!
- subradios 4y agoSo it's a similar set up to what I described, but you do some magic on the backend to do deep analysis and thus client generation for arbitrary functions?
- petermasking 4y agoYes, but without having to build a shared types library, and building API's yourselves. I think we don't use a lot of magic for this. By importing the server functions directly, the IDE (e.g. VSCode) handles the type checking for us. So that's an easy 'trick' to avoid the shared types. Because all imports are handled by Jitar (the repository service), it's fairly easy to replace the actual implementation with a remote implementation. For this we only need to extract the exported functions and their parameters. Some magic happens here.