Please log in to watch this conference skillscast.
A very common situation in web development: you need to make multiple requests, often with some conditions and logic between calls, to get the required result.
It can be achieved in three ways:
Sending multiple requests to the server and implementing all the processing logic in the client. The advantage of this approach is that the server remains unchanged and the client can easily change the logic and flow of requests. The disadvantage is the latency and the traffic - each request should travel via the network.
Implementing additional methods/endpoints/parameters in the server. The advantage of this approach is that the client has to make only one request. The disadvantage is that it requires changing the server (= coding + testing + documenting + deploying + monitoring + supporting...). When it is possible, it inevitably leads to the growing complexity of the remote system as more and more specialised methods/APIs are added to it.
Implement batch endpoints, e.g. using JSON RPC standard. While they allows to execute multiple calls in a single HTTP request, it doesn’t allow to implement any logic between the calls.
JSONScript is a simple tool that allows to create “a batch endpoint on steroids” - server-side scripted execution of existing endpoints and services.
It is currently implemented in express middleware that allows to add JSONScript batch endpoint in a single line of code.
YOU MAY ALSO LIKE:
- Lightning Talk: Coding: You Either Love Or Hate It, Or Why You Should Open-Source For Real. (SkillsCast recorded in July 2019)
- Dependency injection from zero to hero with Koin (SkillsCast recorded in October 2019)
- Automating Elaborate-Transform-Load for Busy Data Scientists (SkillsCast recorded in October 2019)
Batch execution of existing endpoints and services with JSONScript