Ghost/ghost/admin/app/adapters/base.js

41 lines
1022 B
JavaScript
Raw Normal View History

import injectService from 'ember-service/inject';
import RESTAdapter from 'ember-data/adapters/rest';
import ghostPaths from 'ghost-admin/utils/ghost-paths';
2016-01-18 18:37:14 +03:00
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';
import AjaxServiceSupport from 'ember-ajax/mixins/ajax-support';
export default RESTAdapter.extend(DataAdapterMixin, AjaxServiceSupport, {
2016-01-18 18:37:14 +03:00
authorizer: 'authorizer:oauth2',
host: window.location.origin,
namespace: ghostPaths().apiRoot.slice(1),
session: injectService(),
shouldBackgroundReloadRecord() {
return false;
},
query(store, type, query) {
let id;
if (query.id) {
id = query.id;
delete query.id;
}
return this.ajax(this.buildURL(type.modelName, id), 'GET', {data: query});
},
buildURL() {
// Ensure trailing slashes
let url = this._super(...arguments);
if (url.slice(-1) !== '/') {
url += '/';
}
return url;
}
});