jaikamat / clubhouse-pos-importer

Monorepo for an LGS's inventory management system
1 stars 0 forks source link

Reduce suspension payload size #323

Closed jaikamat closed 3 years ago

jaikamat commented 3 years ago

image

Summary

When suspending a sale, we originally passed the transformed SuspendSaleContext state directly to the backend, which persisted it. However, for particularly large lists, the server would issue a 413 Payload too large error, which was frustrating. I intend this PR to be the first step towards streamlining and decoupling the API and frontend from Scryfall's API.

In this PR, we instead pass only the required properties needed to identify a card in a sale, and instead find those cards server-side and persist them, thereby reducing payload size substantially. This involved duplicating the frontend ScryfallCard class to the backend, and using it to transform the raw bulk cards found, which allowed us to match previously suspended sales in a backwards-compatible way.

My hope is that with this class in the backend, we can now pass highly opinionated card objects to the frontend, reducing the need for mapping raw Scryfall card objects we have typically returned using the getCardsWithInfo controller, and greatly reducing (possibly eliminating!) frontend coupling to Scryfall's card object shape.