Skip to content

Commit

Permalink
Clear mirage deprecations
Browse files Browse the repository at this point in the history
In v3.x functions from miragejs will no longer be exported by mirage and
must be pulled directly from miragejs.

The configuration system has been modified to match the upstream
expectations and by more explicit as well.
  • Loading branch information
jrjohnson committed Jan 21, 2022
1 parent 3a4ccc2 commit 42bf812
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion addon/mirage/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import RSVP from 'rsvp';
import Response from 'ember-cli-mirage/response';
import { Response } from 'miragejs';
import { extractFormData, extractFileMetadata } from './utils';

const NETWORK = {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"eslint-plugin-qunit": "^7.0.0",
"fake-xml-http-request": "^2.1.2",
"loader.js": "^4.7.0",
"miragejs": "^0.1.43",
"npm-run-all": "^4.1.5",
"prettier": "^2.3.2",
"qunit": "^2.16.0",
Expand Down
40 changes: 25 additions & 15 deletions tests/dummy/mirage/config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
import { upload } from 'ember-file-upload/mirage';
import { discoverEmberDataModels } from 'ember-cli-mirage';
import { createServer } from 'miragejs';

export default function () {
this.post(
'/photos/new',
upload(function (db, request) {
let { type, name, size, url } = request.requestBody.file;
return db.create('photo', {
filename: name,
filesize: size,
uploadedAt: new Date(),
url,
type: type.split('/')[0],
});
})
);
export default function (config) {
let finalConfig = {
...config,
models: { ...discoverEmberDataModels(), ...config.models },
routes() {
this.post(
'/photos/new',
upload(function (db, request) {
let { type, name, size, url } = request.requestBody.file;
return db.create('photo', {
filename: name,
filesize: size,
uploadedAt: new Date(),
url,
type: type.split('/')[0],
});
})
);

this.passthrough('*');
this.passthrough('*');
},
};

return createServer(finalConfig);
}
2 changes: 1 addition & 1 deletion tests/dummy/mirage/models/photo.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { Model } from 'ember-cli-mirage';
import { Model } from 'miragejs';

export default class Photo extends Model {}

0 comments on commit 42bf812

Please sign in to comment.