How to use the ember-data.JSONAPIAdapter function in ember-data

To help you get started, we’ve selected a few ember-data examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 7cart / 7cart / front / app / adapters / application.js View on Github external
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'
github cardstack / cardstack / packages / models / addon / adapter.js View on Github external
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) {
github Nanocloud / community / webapp / app / application / adapter.js View on Github external
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'
});
github alphasights / ember-graphql-adapter / tests / helpers / store.js View on Github external
}

  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;
}
github apache / hadoop / hadoop-yarn-project / hadoop-yarn / hadoop-yarn-ui / src / main / webapp / app / adapters / abstract.js View on Github external
* 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}`);
github berkmancenter / dotplot / app / adapters / application.js View on Github external
import DS from 'ember-data';
import config from '../config';

export default DS.JSONAPIAdapter.extend({
  host: config.endpoints.server.host,
  namespace: config.endpoints.server.namespace
});
github mike-works / ember-fundamentals / app / adapters / application.js View on Github external
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);
        }
    }
});
github ember-learn / ember-website / app / adapters / application.js View on Github external
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`;
  },
github muffin / client / app / adapters / application.js View on Github external
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'
})
github linkedin / dr-elephant / web / app / adapters / application.js View on Github external
* 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);
  }
});