Currently when we update map images or credits on the frontend, we have to send a big batch of individual HTTP requests for each change. I really dislike this approach, as it spams our backend - with writes!
Array checks are one of least upsetting type-checks in JavaScript, we can easily allow these endpoints to receive and return DTO | DTO[] and do a type guard. The actual create/update/delete logic can be done in separate private functions which are either called once (individual DTOs) or multiple times (arrays).
We could only accept arrays, but we are an API, accepting single values seems reasonable.
Once the backend is refactored, update the frontend code to use arrays (singleton arrays ares fine of course). Should make that code significantly simpler, especially given some of the RxJS forkJoins we have to do because of the current system.
Note, for the new MapTestingRequest endpoints we'll be supporting this pattern out of the box.
Currently when we update map images or credits on the frontend, we have to send a big batch of individual HTTP requests for each change. I really dislike this approach, as it spams our backend - with writes!
Array checks are one of least upsetting type-checks in JavaScript, we can easily allow these endpoints to receive and return
DTO | DTO[]
and do a type guard. The actual create/update/delete logic can be done in separate private functions which are either called once (individual DTOs) or multiple times (arrays).We could only accept arrays, but we are an API, accepting single values seems reasonable.
Once the backend is refactored, update the frontend code to use arrays (singleton arrays ares fine of course). Should make that code significantly simpler, especially given some of the RxJS
forkJoin
s we have to do because of the current system.Note, for the new
MapTestingRequest
endpoints we'll be supporting this pattern out of the box.