2020-02-14 14:07:25 +03:00
|
|
|
import {paginatedResponse} from '../utils';
|
|
|
|
|
|
|
|
export default function mockLabels(server) {
|
2022-02-23 17:21:28 +03:00
|
|
|
server.post('/labels/');
|
2020-02-14 14:07:25 +03:00
|
|
|
server.get('/labels/', paginatedResponse('labels'));
|
|
|
|
|
|
|
|
server.get('/labels/:id/', function ({labels}, {params}) {
|
|
|
|
let {id} = params;
|
|
|
|
let label = labels.find(id);
|
|
|
|
|
|
|
|
return label || new Response(404, {}, {
|
|
|
|
errors: [{
|
|
|
|
type: 'NotFoundError',
|
|
|
|
message: 'Label not found.'
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
server.put('/labels/:id/');
|
|
|
|
|
|
|
|
server.del('/labels/:id/');
|
|
|
|
}
|