17 // this.timing = 400; // delay for each request, automatically set to 0 during testing |
17 // this.timing = 400; // delay for each request, automatically set to 0 during testing |
18 |
18 |
19 this.get('/documents', function({ documents }) { |
19 this.get('/documents', function({ documents }) { |
20 return this.serialize(documents.all(), 'sparse-document'); |
20 return this.serialize(documents.all(), 'sparse-document'); |
21 }); |
21 }); |
|
22 |
22 this.get('/documents/:id', ({documents}, request) => { |
23 this.get('/documents/:id', ({documents}, request) => { |
23 let id = decodeURIComponent(request.params.id); |
24 let id = decodeURIComponent(request.params.id); |
24 return documents.find(id); |
25 return documents.find(id); |
25 }); |
26 }); |
26 |
27 |
27 this.get('/documents/:id/transcript', ({transcripts}, request) => { |
28 this.get('/documents/:id/transcript', ({transcripts}, request) => { |
28 let id = decodeURIComponent(request.params.id); |
29 let id = decodeURIComponent(request.params.id); |
29 |
|
30 return transcripts.find(id).transcript; |
30 return transcripts.find(id).transcript; |
31 }); |
31 }); |
32 |
32 |
33 this.get('/languages'); |
33 this.get('/languages'); |
34 |
34 |
45 } |
45 } |
46 var lexvoRes = lexvos.find(fullId); |
46 var lexvoRes = lexvos.find(fullId); |
47 res[id] = lexvoRes?lexvoRes.name:null; |
47 res[id] = lexvoRes?lexvoRes.name:null; |
48 return res; |
48 return res; |
49 }, {}); |
49 }, {}); |
50 |
|
51 return { |
50 return { |
52 'lexvoids': resMap |
51 'lexvoids': resMap |
53 }; |
52 }; |
54 |
|
55 }); |
53 }); |
56 |
54 |
57 this.get('/bnf/:ids', ({ bnfs }, request) => { |
55 this.get('/bnf/:ids', ({ bnfs }, request) => { |
58 |
|
59 var bnfIds = decodeURIComponent(request.params.ids); |
56 var bnfIds = decodeURIComponent(request.params.ids); |
60 var resMap = _.reduce(bnfIds.split(','), function(res, id) { |
57 var resMap = _.reduce(bnfIds.split(','), function(res, id) { |
61 var fullId = id; |
58 var fullId = id; |
62 if(_.startsWith(fullId, constants.BNF_BASE_URL)) { |
59 if(_.startsWith(fullId, constants.BNF_BASE_URL)) { |
63 fullId = fullId.slice(constants.BNF_BASE_URL.length); |
60 fullId = fullId.slice(constants.BNF_BASE_URL.length); |