cms/app-client/mirage/config.js
changeset 245 c9dd78a43b07
parent 173 cf7b221238fd
child 261 02e2396bcbbc
equal deleted inserted replaced
244:d7ab83ecf737 245:c9dd78a43b07
    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);
    68             }
    65             }
    69             var bnfRes = bnfs.find(fullId);
    66             var bnfRes = bnfs.find(fullId);
    70             res[id] = bnfRes?bnfRes.label:null;
    67             res[id] = bnfRes?bnfRes.label:null;
    71             return res;
    68             return res;
    72         }, {});
    69         }, {});
    73 
       
    74         return {
    70         return {
    75             'bnfids': resMap
    71             'bnfids': resMap
    76         };
    72         };
    77 
       
    78     });
    73     });
    79 
    74 
    80 
    75 
    81 }
    76 }