diff --git a/app/adapters/application.js b/app/adapters/application.js index 9543dad..eff47fc 100644 --- a/app/adapters/application.js +++ b/app/adapters/application.js @@ -1,12 +1,28 @@ +import { get } from '@ember/object'; +import { inject as service } from '@ember/service'; import JSONAPIAdapter from 'ember-data/adapters/json-api'; -import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin'; +import AdapterFetchMixin from 'ember-fetch/mixins/adapter-fetch'; import config from 'mir/config/environment'; -export default JSONAPIAdapter.extend(DataAdapterMixin, { +export default JSONAPIAdapter.extend(AdapterFetchMixin, { + session: service(), + /* Ember */ host: config.DS.host, namespace: config.DS.namespace, /* DataAdapterMixin */ - authorizer: 'authorizer:oauth2' + authorizer: 'authorizer:oauth2', + + /* mir */ + ajaxOptions() { + const authorizer = get(this, 'authorizer'); + const options = this._super(...arguments) || {}; + options.headers = options.headers || {}; + options.headers['Content-Type'] = 'application/vnd.api+json'; + get(this, 'session').authorize(authorizer, (headerName, headerValue) => { + options.headers[headerName] = headerValue; + }); + return options; + } }); diff --git a/ember-cli-build.js b/ember-cli-build.js index 9e8dbf7..077cf9f 100644 --- a/ember-cli-build.js +++ b/ember-cli-build.js @@ -7,7 +7,6 @@ const VERSION = GETENVJSON().version; module.exports = function(defaults) { let app = new EmberApp(defaults, { - // Add options here fingerprint: { extensions: ['css', 'gif', 'js', 'jpg', 'png', 'map', 'svg'] }, @@ -30,6 +29,10 @@ module.exports = function(defaults) { svgJar: { sourceDirs: ['public/images'] + }, + + vendorFiles: { + 'jquery.js': null // removes jQuery from build } }); diff --git a/mirage/config.js b/mirage/config.js index 7acb79f..984ea2e 100644 --- a/mirage/config.js +++ b/mirage/config.js @@ -71,5 +71,7 @@ export default function() { this.del('/medias/:id', (schema, request) => { let media = schema.medias.find(request.params.id); media.destroy(); + // TODO: Hacks + return { data: null }; // i shouldn't have to return anything here }); }