Open andywer opened 8 years ago
@romansemko pointed out that Angular (1.x) has $resource which is pretty similar to that. But Angular-specific, of course... Angular 2 doesn't seem to have it yet: https://www.npmjs.com/package/angular2-resource
Would be important for it to be as framework-agnostic as possible, though.
Have you checked: https://github.com/ngonzalvez/rest-facade
@romansemko Good hint, thanks! It could be a little more up-to-date (isomorphic-fetch instead of superagent) and a little less ID-centric, but seems like a valid option.
I've got to check if the enumerable properties of a resource instance are equal to the transferred REST object (I think this is pretty important for nice and stress-free development).
@romansemko Seems like https://github.com/ngonzalvez/rest-facade just returns the pure data, not instances with href-aware CRUD methods on the prototype :-/
Hmm. That is as close as it gets. Might need to write own stuff after all...
Just for completeness:
This is closer to what I had in mind, but I think its API feels a little inconvenient: https://github.com/marmelab/restful.js
Also it is focused towards a pretty narrow API layout which might not work with every RESTful API. HATEOAS has not even been considered, I guess :-/
Looks like one of the closest solutions right now, build on the shoulders of GraphQL: https://github.com/stubailo/graphql-anywhere
I think it would be very useful to have something like an ORM for the frontend to fetch and manipulate REST resources. Especially if your backend goes an HATEOASish approach, since you want a tight coupling of resource and href (see https://www.npmjs.com/package/hal). There seems to be no suitable solution out there: https://www.google.de/search?q=redux%20hateoas
Idea: