mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 02:11:44 +03:00
9adbcd1fd0
no issue Automated tools, code generators, and editor integrations are increasingly standardising on the import style used in `ember-modules-codemod`. Our import style differed a little with regards to service/controller injection imports which meant we were starting to see inconsistent naming.
41 lines
1016 B
JavaScript
41 lines
1016 B
JavaScript
import AjaxServiceSupport from 'ember-ajax/mixins/ajax-support';
|
|
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';
|
|
import RESTAdapter from 'ember-data/adapters/rest';
|
|
import ghostPaths from 'ghost-admin/utils/ghost-paths';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default RESTAdapter.extend(DataAdapterMixin, AjaxServiceSupport, {
|
|
authorizer: 'authorizer:oauth2',
|
|
|
|
host: window.location.origin,
|
|
namespace: ghostPaths().apiRoot.slice(1),
|
|
|
|
session: service(),
|
|
|
|
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;
|
|
}
|
|
});
|