Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import DS from 'ember-data';
import config from 'front/config/environment';
import { isPresent } from '@ember/utils';
import { computed } from '@ember/object';
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';
import { inject as service } from '@ember/service';
import FastbootAdapter from 'ember-data-storefront/mixins/fastboot-adapter';
export default DS.JSONAPIAdapter.extend(DataAdapterMixin, FastbootAdapter, {
fastboot: service(),
host: computed('fastboot.isFastBoot', function() {
let fastboot = this.fastboot;
if (fastboot.isFastBoot) {
// docker network alias
return config.APP.backendDockerHost;
} else {
return config.APP.backendHost;
}
}),
namespace: config.APP.backendNamespace,
init() {
this._super(...arguments);
this.headers = {
'Accept-Language':'en'
import { assign } from '@ember/polyfills';
import { get } from '@ember/object';
import DS from 'ember-data';
import AdapterMixin from 'ember-resource-metadata/adapter-mixin';
import { hubURL } from '@cardstack/plugin-utils/environment';
import injectOptional from 'ember-inject-optional';
export default DS.JSONAPIAdapter.extend(AdapterMixin, {
host: hubURL,
namespace: 'api',
cardstackSession: injectOptional.service(),
session: injectOptional.service(),
pathForType(modelName) {
if (modelName === 'cardstack-card') {
return '';
} else {
return this._super(...arguments);
}
},
// queryRecord can use the hub's page.size control to just do a
// query of with a limit of 1.
async queryRecord(store, type, query) {
import DS from 'ember-data';
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';
export default DS.JSONAPIAdapter.extend(DataAdapterMixin, {
// Tells ember-data to send user acecss_token alongside every requests
authorizer: 'authorizer:oauth2',
// All request to api will be made on HOST/api
namespace: 'api'
});
}
registry.register('service:store', DS.Store.extend({
adapter: adapter
}));
registry.optionsForType('serializer', { singleton: false });
registry.optionsForType('adapter', { singleton: false });
registry.register('adapter:-default', DS.Adapter);
registry.register('serializer:-default', DS.JSONSerializer);
registry.register('serializer:-rest', DS.RESTSerializer);
registry.register('adapter:-rest', DS.RESTAdapter);
registry.register('adapter:-json-api', DS.JSONAPIAdapter);
registry.register('serializer:-json-api', DS.JSONAPISerializer);
registry.register('adapter:-graphql', Adapter);
registry.register('serializer:-graphql', Serializer);
registry.register('transform:string', DS.StringTransform);
registry.register('transform:number', DS.NumberTransform);
env.restSerializer = container.lookup('serializer:-rest');
env.store = container.lookup('service:store');
env.serializer = env.store.serializerFor('-default');
env.adapter = env.store.get('defaultAdapter');
return env;
}
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ember from 'ember';
import DS from 'ember-data';
export default DS.JSONAPIAdapter.extend({
address: null, //Must be set by inheriting classes
restNameSpace: null, //Must be set by inheriting classes
serverName: null, //Must be set by inheriting classes
headers: {
Accept: 'application/json'
},
host: Ember.computed("address", function () {
var address = this.get("address");
return this.get(`hosts.${address}`);
}),
namespace: Ember.computed("restNameSpace", function () {
var serverName = this.get("restNameSpace");
return this.get(`env.app.namespaces.${serverName}`);
import DS from 'ember-data';
import config from '../config';
export default DS.JSONAPIAdapter.extend({
host: config.endpoints.server.host,
namespace: config.endpoints.server.namespace
});
import DS from 'ember-data';
export default DS.JSONAPIAdapter.extend({
host: 'https://api.mike.works',
namespace: 'api/v1',
urlForQueryRecord (query , modelName) {
let {courseId, stage} = query;
switch(modelName) {
case 'course-stage':
delete query.courseId;
delete query.stage;
return `${this.urlForFindRecord(courseId, 'course')}/stages/${stage}`;
default:
return this._super(...arguments);
}
}
});
import DS from 'ember-data';
import AdapterFetch from 'ember-fetch/mixins/adapter-fetch';
import { inject as service } from '@ember/service';
import { computed } from '@ember/object';
export default DS.JSONAPIAdapter.extend(AdapterFetch, {
fastboot: service(),
host: computed('fastboot.isFastBoot', function() {
if (this.get('fastboot.isFastBoot')) {
let protocol = this.get('fastboot.request.protocol');
return `${protocol}//${this.get('fastboot.request.host')}`;
} else {
return window.location.origin;
}
}),
urlForFindAll(modelName) {
const path = this.pathForType(modelName);
return `${this.host}/data/${path}/all.json`;
},
import DS from 'ember-data'
import DataAdapter from 'ember-simple-auth/mixins/data-adapter-mixin'
export default DS.JSONAPIAdapter.extend(DataAdapter, {
namespace: 'api',
authorizer: 'authorizer:token'
})
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import DS from 'ember-data';
import Ember from 'ember';
export default DS.JSONAPIAdapter.extend({
namespace: 'rest'
});
export default DS.RESTAdapter.extend({
namespace: 'rest',
pathForType: function (type) {
return Ember.String.pluralize(type);
}
});