11 |
11 |
12 Note: these only affect routes defined *after* them! |
12 Note: these only affect routes defined *after* them! |
13 */ |
13 */ |
14 // this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server |
14 // this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server |
15 // this.namespace = ''; // make this `api`, for example, if your API is namespaced |
15 // this.namespace = ''; // make this `api`, for example, if your API is namespaced |
16 this.namespace = ENV.rootURL.replace(/\/$/,'')+'/api/v1'; |
16 this.namespace = (ENV.APP.backRootURL || ENV.rootURL).replace(/\/$/,'')+'/api/v1'; |
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 |
23 this.get('/documents/:id', ({documents}, request) => { |
23 this.get('/documents/:id', ({documents}, request) => { |
24 let id = decodeURIComponent(request.params.id); |
24 let id = decodeURIComponent(decodeURIComponent(request.params.id)); |
25 return documents.find(id); |
25 return documents.find(id); |
26 }); |
26 }); |
27 |
27 |
28 this.get('/documents/:id/transcript', ({transcripts}, request) => { |
28 this.get('/documents/:id/transcript', ({transcripts}, request) => { |
29 let id = decodeURIComponent(request.params.id); |
29 let id = decodeURIComponent(decodeURIComponent(request.params.id)); |
30 return transcripts.find(id).transcript; |
30 return transcripts.find(id).transcript; |
31 }); |
31 }); |
32 |
32 |
33 this.get('/stats/languages', 'languages'); |
33 this.get('/stats/languages', 'languages'); |
34 |
34 |
42 |
42 |
43 this.get('/resolvers/lexvo/:ids', ({lexvos}, request) => { |
43 this.get('/resolvers/lexvo/:ids', ({lexvos}, request) => { |
44 var langIds = decodeURIComponent(request.params.ids); |
44 var langIds = decodeURIComponent(request.params.ids); |
45 var resMap = _.reduce(langIds.split(','), function(res, id) { |
45 var resMap = _.reduce(langIds.split(','), function(res, id) { |
46 var fullId = id; |
46 var fullId = id; |
47 if(!_.startsWith(fullId, constants.LEXVO_BASE_URL)) { |
47 if(!_.startsWith(fullId, constants.LEXVO_BASE_URL) && !_.startsWith(fullId, constants.LANGUAGES_NODE_PREFIX)) { |
48 fullId = constants.LEXVO_BASE_URL + id; |
48 fullId = constants.LEXVO_BASE_URL + id; |
49 } |
49 } |
50 var lexvoRes = lexvos.find(fullId); |
50 var lexvoRes = lexvos.find(fullId); |
51 res[id] = lexvoRes?lexvoRes.name:null; |
51 res[id] = lexvoRes?lexvoRes.name:null; |
52 return res; |
52 return res; |