Skip to content

Commit

Permalink
Implement /process_graphs/:id endpoint (addresses #20 point 4)
Browse files Browse the repository at this point in the history
Compliant to openEO API v0.4.2.

The Hub now supports `GET /process_graphs`, `POST /process_graphs`, and `GET /process_graphs/{process_graph_id}`.

The Hub does not support  any authentication, i.e. *everybody* can submit process graphs and *everybody* can access them. (That's also the reason why the PATCH and DELETE endpoints are not supported, i.e. why point 5 of #20 is not yet addressed.)
  • Loading branch information
christophfriedrich committed Sep 4, 2019
1 parent a6c2e5e commit dd3d267
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,24 @@ server.post('/process_graphs', function(req, res, next) {
.catch(err => next(err));
});

// compliant to openEO API 0.4.2
server.get('/process_graphs/:id', function(req, res, next) {
findOne(mongodb.ObjectId(req.params.id), 'process_graphs')
.then(pg => {
if(pg) {
pg.id = pg._id;
delete pg._id;
res.send(pg);
next();
} else {
res.statusCode = 404;
res.send({message: "Not Found"});
next();
}
})
.catch(err => next(err));
});

// serve website (UI)
server.get('/*', restify.plugins.serveStatic({
directory: './dist',
Expand Down

0 comments on commit dd3d267

Please sign in to comment.