Skip to content

Commit

Permalink
[#31] Remove jQuery
Browse files Browse the repository at this point in the history
* [x] Strip jQuery in ember-cli-build.js
* [x] Try to ember-data to use ember-fetch instead of $.ajax
* [x] app/adapters/application.js added the authorization: <bearer token> header to outgoing requests
* [x] ma-create-media guards against disabled button
* [x] updated dependencies
  • Loading branch information
0xadada committed Mar 8, 2018
1 parent 732de5b commit ab55c8b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
22 changes: 19 additions & 3 deletions app/adapters/application.js
Original file line number Diff line number Diff line change
@@ -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;
}
});
5 changes: 4 additions & 1 deletion ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']
},
Expand All @@ -30,6 +29,10 @@ module.exports = function(defaults) {

svgJar: {
sourceDirs: ['public/images']
},

vendorFiles: {
'jquery.js': null // removes jQuery from build
}
});

Expand Down
2 changes: 2 additions & 0 deletions mirage/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}

0 comments on commit ab55c8b

Please sign in to comment.