Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Improved annotations route.

  • Loading branch information...
rasvaan committed Jan 18, 2017
1 parent f938a6d commit fdab6587e53b1df2b9c13329e6afd4b6a56d64c8
Showing with 21 additions and 24 deletions.
  1. +2 −1 src/middlewares/triple-store.js
  2. +19 −23 src/routes/index.js
@@ -18,7 +18,8 @@ module.exports = {
body: query
};

return request(options).then(response => {
return request(options)
.then(response => {
return JSON.parse(response).results.bindings;
});
},
@@ -32,33 +32,29 @@ module.exports.set = function(app) {
.catch(error => { next(error); });
});

app.get('/annotations', function(req, res) {
app.get('/annotations', function(req, res, next) {
const parameters = interpret.annotationParameters(req.query);

if (parameters) {
if (parameters.date) {
parameters.request = 'annotations_since';
if (parameters.date) {
parameters.request = 'annotations_since';

platformAnnotations.since(parameters)
.then(function(results) {
let jsonLd = results.toJSONLD();
// reply results according to request header
output.contentNegotiation(res, jsonLd);
}, function(error) {
res.status(404).send(error.message);
});
} else {
parameters.request = 'annotations';
platformAnnotations.since(parameters)
.then(function(results) {
let jsonLd = results.toJSONLD();
// reply results according to request header
output.contentNegotiation(res, jsonLd);
})
.catch(error => { next(error); });
} else {
parameters.request = 'annotations';

platformAnnotations.get(parameters)
.then(function(results) {
let jsonLd = results.toJSONLD();
// reply results according to request header
output.contentNegotiation(res, jsonLd);
}, function(error) {
res.status(404).send(error.message);
});
}
platformAnnotations.get(parameters)
.then(function(results) {
let jsonLd = results.toJSONLD();
// reply results according to request header
output.contentNegotiation(res, jsonLd);
})
.catch(error => { next(error); });
}
});

0 comments on commit fdab658

Please sign in to comment.
You can’t perform that action at this time.