tweaselORG / parse-tunes

Library for fetching select data on iOS apps from the Apple App Store via undocumented internal iTunes APIs.
MIT License
10 stars 1 forks source link

Decide how we should handle unexpected responses #5

Open baltpeter opened 1 year ago

baltpeter commented 1 year ago

We are using undocumented internal API endpoints. This mean we have to expect them to change or even stop working entirely at any time without notice. How do we want to deal with that?

Currently, we don't have any validation of the returned response whatsoever. If the response is not as we expected, we will just crash.

In parse-play, I added a few basic assertions:

https://github.com/baltpeter/parse-play/blob/3227d26f8c5a2f8fdab2bcd90287c8c60a1ceff8/src/top-charts.ts#L97

But I only fire them when an env var is set:

https://github.com/baltpeter/parse-play/blob/3227d26f8c5a2f8fdab2bcd90287c8c60a1ceff8/src/common/assert.ts#L5

A cleaner implementation would be to use zod.