2019-01-22 20:18:44 +03:00
|
|
|
import {paginatedResponse} from '../utils';
|
|
|
|
|
|
|
|
export default function mockMembers(server) {
|
2019-11-28 14:30:21 +03:00
|
|
|
server.post('/members/', function ({members}) {
|
|
|
|
let attrs = this.normalizedRequestAttrs();
|
|
|
|
|
|
|
|
return members.create(Object.assign({}, attrs, {id: 99}));
|
|
|
|
});
|
|
|
|
|
2019-01-22 20:18:44 +03:00
|
|
|
server.get('/members/', paginatedResponse('members'));
|
2019-02-22 14:31:45 +03:00
|
|
|
|
|
|
|
server.get('/members/:id/', function ({members}, {params}) {
|
|
|
|
let {id} = params;
|
|
|
|
let member = members.find(id);
|
|
|
|
|
|
|
|
return member || new Response(404, {}, {
|
|
|
|
errors: [{
|
2019-03-25 14:29:14 +03:00
|
|
|
type: 'NotFoundError',
|
2019-02-22 14:31:45 +03:00
|
|
|
message: 'Member not found.'
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-11-28 14:30:21 +03:00
|
|
|
server.put('/members/:id/');
|
|
|
|
|
2019-02-22 14:31:45 +03:00
|
|
|
server.del('/members/:id/');
|
2019-01-22 20:18:44 +03:00
|
|
|
}
|