You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the API response shape I propose to have something like below. I know might look a bit over engineering for the existing functionality but general API shape is something that is very difficult to change after :)
// for success
{ success: 1, payload: any }
// for error
{ success: 0, error: { message: "Wrong API call", detail: any } }
payload can be of any shape (depending on the specific endpoint)
error detail - will probably be either array with errors, or object shape similar to request with errors instead of data attrs
Input validation, a bit in doubts:
just ignore for now (i don't like , this is a ground concept)
use some of standard libs. One is very typescript friendly - https://www.npmjs.com/package/class-validator - but looks a bit bloated for me, and requires classes instead of interfaces which imho corrupts the beauty of TS
Use https://github.com/koorchik/js-validator-livr - a very lightweight, descriptive approach, no dependencies. Used it before, no issues (and I know the author - not sure if it is + or - - but they support and use it quite intesively so it does not go anywhere ;)
The text was updated successfully, but these errors were encountered:
LIVR: looks good for javascript, but in typescript we can define the types, and the input data should correspond to the types defined
I'm not sure what the easiest way to do this in typescript is, but I'd like to avoid having to do double typing.
eg. https://schema.abaplint.org/schema.json is generated automatically from the typescript code, in this validation scenario the input could be validated according to a json schema
For the API response shape I propose to have something like below. I know might look a bit over engineering for the existing functionality but general API shape is something that is very difficult to change after :)
Input validation, a bit in doubts:
+
or-
- but they support and use it quite intesively so it does not go anywhere ;)The text was updated successfully, but these errors were encountered: