Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save visualjeff/152ddde6922b5ae75285cbc841888acb to your computer and use it in GitHub Desktop.
Save visualjeff/152ddde6922b5ae75285cbc841888acb to your computer and use it in GitHub Desktop.
Mirage cheatsheet
Mirage cheatsheet:
1. Install Mirage: ember install ember-cli-mirage
2. Set namespace in mirage/config.js
3. Set route handler in mirage/config.js
4. Generate mirage model. ember g mirage-model <model_name>
5. If you not using JSONAPI. Customize your mirage serializer
6. Seed the database: ember g mirage-fixture <fixture_name>
7. Remove senarios directory. It prevents fixtures being load. rm -rf senarios
8. Refactor to use shorthands where possible.
this.get('/bands', function(schema, request) {
return schema.bands.all();
});
this.post('/bands', function(schema, request) {
let attrs = JSON.parse(request.requestBody).band;
return schema.bands.create(attrs);
});
Becomes:
this.get('/bands');
this.post('/bands');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment