jakubrohleder / angular-jsonapi

Simple and lightweight, yet powerful ORM for your frontend that seamlessly integrates with your JsonAPI server.
http://jakubrohleder.github.io/angular-jsonapi/
GNU General Public License v3.0
94 stars 34 forks source link

One resource, different REST endpoints #32

Open mustela opened 8 years ago

mustela commented 8 years ago

I'm wondering if there is a way to synchronise a resource in a conditional way. Since I have resources that can be modified from different end points. For example:

Resource: Organizations

You can GET organizations doing: api.com/organizations or you can do api.com/backend/organizations, but you can't PUT api.com/organizations, you have to PUT api.com/backend/organizations

If you are a "regular" user, you will be using api.com/organizations entry point, but if you are in the backend section of the app, you will need to use api.com/backend/organizations, since more operations are allowed.

So I can only think 2 approaches for now:

  1. I could duplicate the factories and have 2 Organizations factories, one pointing to api.com and the other pointing to api.com/backend, duplicating schemas, and everything.
  2. Replace synchronizer at "runtime". I'm not sure if this possible, but if I could swap between a one of the other synchronizer when requesting the factory (or similar) I think it could work.
  3. Another?

Hope the explanation is clear enough.

Thanks