Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import config from 'travis/config/environment';
import Ember from 'ember';
import ActiveModelAdapter from 'active-model-adapter';
const { service } = Ember.inject;
export default ActiveModelAdapter.extend({
auth: service(),
features: service(),
host: config.apiEndpoint,
coalesceFindRequests: true,
// Before Ember Data 2.0 the default behaviour of running `findAll` was to get
// new records only when there're no records in the store. This will change
// to a different strategy in 2.0: when you run `findAll` it will not get any
// new data initially, but it will try loading new data in the background.
//
// I'm disabling the new behaviour for now.
shouldBackgroundReloadRecord() {
return false;
},
ajaxOptions() {
import ActiveModelAdapter from 'active-model-adapter';
export default ActiveModelAdapter.extend({
namespace: 'api'
});
import ActiveModelAdapter from 'active-model-adapter';
export default ActiveModelAdapter.extend({
namespace: 'api'
});
import ActiveModelAdapter from 'active-model-adapter';
export default ActiveModelAdapter.extend({
namespace: 'api'
});
import ActiveModelAdapter from 'active-model-adapter';
export default ActiveModelAdapter.extend({
host: 'http://localhost:3009'
});
import ActiveModelAdapter from 'active-model-adapter';
export default ActiveModelAdapter.extend({
namespace: 'api/v4',
coalesceFindRequests: true
});
import ActiveModelAdapter from 'active-model-adapter';
export default ActiveModelAdapter.extend({
host: 'https://api.github.com',
queryUrl: 'https://api.github.com/search',
buildURL(modelName, id, snapshot, requestType) {
if(requestType === 'query') {
this.host = this.queryUrl
}
return this._super(...arguments);
}
});
import Ember from 'ember';
import ActiveModelAdapter from 'active-model-adapter';
const urlJoin = requireNode('url-join'),
lodash = requireNode('lodash'),
url = requireNode('url');
export default ActiveModelAdapter.extend({
configuration: Ember.inject.service(),
host: Ember.computed(function() {
return this.get('configuration.xapi');
}),
addKeyParam(fullUrl) {
let params = url.parse(fullUrl, true).query,
apiKey = this.get('configuration.apiKey'),
suffix = '';
if (lodash.isEmpty(params)) {
suffix = `?key=${apiKey}`;
} else if (!params.key) {
suffix = `&key=${apiKey}`;
}
return `${fullUrl}${suffix}`;
import Ember from 'ember';
import ActiveModelAdapter from 'active-model-adapter';
import ENV from '../config/environment';
export default ActiveModelAdapter.extend({
host: ENV.apiHost,
auth: Ember.inject.service(),
headers: Ember.computed('auth.credentials.token', {
get () {
let headers = {};
const token = this.get('auth.credentials.token');
if (token) {
headers.Authorization = `Token token=${token}`;
}
return headers;
},
}),
});