First I would like to say, thank you for such a great framework. I am new to Ember JS, I’m using it since 4th of may 2015. The project in which I am one and only front-end developer is a combination of .NET API, two mobile (iOS and Android) thin clients and one Web thick client (which of course I have to develop).
In this project, we have at the beginning following controllers(.netters call them resources): Base, Bug, KnowledgeBase, Notifications, RefreshTokens, Roles. I am sure that it will be much more of them. The thing is, that URIs do not adhere to DS.RESTAdapter, nor to the Ember-data at all. For example here is the list of URIs for ‘Account’ resource:
Account Operations POST /api/v1/account/register POST /api/v1/account/edit POST /api/v1/account/delete GET /api/v1/account/user GET /api/v1/account/get/{id} POST /api/v1/account/changepassword
They are not moot, I can’t make them more ‘emberish’, it is not my duty. Taking this URI for example: “GET /api/v1/account/user” - it has no :id, it just gets account data of current logged in user based on the “Authorization” header used in Ajax GET call to /api/v1/account/user. Header keeps a token like this “hg7mCD4ii8cTr0hpUjSPRx6UlQsD_mEhR…”.
I managed to read some tutorials (Evil Trout), watch some videocasts and I finally did remove ember-data from project (npm rm ember-data --save-dev). I remove it because I couldn’t manage to resolve at once:
- Ember-data incompatibility with our API URIs
- Ember-cli’s convention over configuration (ember-cli is what I’m using for this project)
- Ajaxmockups with NodeJS Express and constant CORS exceptions showing in Chrome’s DevTools.
Then I developed store and adapter in the way described here: http://blog.bndw.org/building-a-custom-store-and-adapter-in-ember-cli/
Now I am stuck with few unknowns:
- Do I have hold to the method names used in Ember-data Adapters (_buildURL ajaxError ajaxSuccess buildURL createRecord deleteRecord find findBelongsTo findHasMany findMany updateRecord urlForCreateRecord…) to get my custom adapter work properly with Ember JS.
- Does my adapter methods has to have the same parameters (eg. find (store, type, id, snapshot)), buildURL (modelName, id, snapshot, requestType, query)
- How to manage Ember.$.ajax headers for inbound (same domain) requests and CORS? Eg: when calling outside API with JSON Ajax call with header Authoriazion set with token, I got 40X errors…
- Does store has to be one in whole application? Can it use multiple adapters (one adapter for each APIs Resource (URI))?
Thanks for reading, sorry about my english. Best regards!