-
-
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.
- Loading branch information
Showing
5 changed files
with
29 additions
and
18 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 {} |