-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. Using embroider macros we can detect if ember-cli-mirage and miragejs are present and only include this code when that is true. For our own local tests we then add mirage as a dev dependency and require it as an optional peer dependency so embroider will know how it should work. * Move ember-auto-import to dependencies This is required for the importSync embroiderr macro to work.
- Loading branch information
Showing
6 changed files
with
1,668 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { JSONAPISerializer } from 'ember-cli-mirage'; | ||
import { JSONAPISerializer } from 'miragejs'; | ||
|
||
export default class ApplicationSerializer extends JSONAPISerializer {} |
Oops, something went wrong.