Skip to content

Commit 36defc1

Browse files
committed
Move app/mirage to mirage
So that the mirage fixtures aren't included in the production build. http://www.ember-cli-mirage.com/docs/v0.2.x/upgrading/#x--02-upgrade-guide
1 parent fcf74aa commit 36defc1

File tree

7 files changed

+23
-60
lines changed

7 files changed

+23
-60
lines changed

app/mirage/config.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

app/mirage/scenarios/default.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

mirage/config.js

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
1-
export default function() {
1+
import summaryFixture from '../mirage/fixtures/summary';
2+
import searchFixture from '../mirage/fixtures/search';
3+
import categoriesFixture from '../mirage/fixtures/categories';
24

3-
// These comments are here to help you get started. Feel free to delete them.
5+
export default function() {
6+
this.get('/summary', () => summaryFixture);
47

5-
/*
6-
Config (with defaults).
8+
this.get('/api/v1/crates', (db, request) => {
9+
if (request.queryParams.q) {
10+
const { start, end } = pageParams(request);
11+
return {
12+
crates: searchFixture.crates.slice(start, end),
13+
meta: searchFixture.meta,
14+
};
15+
}
16+
});
717

8-
Note: these only affect routes defined *after* them!
9-
*/
18+
this.get('/api/v1/categories', () => categoriesFixture);
19+
}
1020

11-
// this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server
12-
// this.namespace = ''; // make this `api`, for example, if your API is namespaced
13-
// this.timing = 400; // delay for each request, automatically set to 0 during testing
21+
function pageParams(request) {
22+
const { queryParams } = request;
1423

15-
/*
16-
Shorthand cheatsheet:
24+
const page = parseInt(queryParams.page);
25+
const perPage = parseInt(queryParams.per_page);
1726

18-
this.get('/posts');
19-
this.post('/posts');
20-
this.get('/posts/:id');
21-
this.put('/posts/:id'); // or this.patch
22-
this.del('/posts/:id');
27+
const start = (page - 1) * perPage;
28+
const end = start + perPage;
2329

24-
http://www.ember-cli-mirage.com/docs/v0.2.x/shorthands/
25-
*/
30+
return { page, perPage, start, end };
2631
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

mirage/scenarios/default.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,2 @@
11
export default function(/* server */) {
2-
3-
/*
4-
Seed your development database using your factories.
5-
This data will not be loaded in your tests.
6-
7-
Make sure to define a factory for each model you want to create.
8-
*/
9-
10-
// server.createList('post', 10);
112
}

0 commit comments

Comments
 (0)