Middlewarify analysis-node-status endpoint

This commit is contained in:
Daniel García Aubert
2018-03-05 18:13:19 +01:00
parent 40712a2e62
commit d8a4209768
+12 -17
View File
@@ -163,31 +163,26 @@ LayergroupController.prototype.register = function(app) {
cors(),
userMiddleware,
this.prepareContext,
this.analysisNodeStatus.bind(this)
this.analysisNodeStatus(this.analysisStatusBackend)
);
};
LayergroupController.prototype.analysisNodeStatus = function(req, res, next) {
var self = this;
step(
function retrieveNodeStatus() {
self.analysisStatusBackend.getNodeStatus(res.locals, this);
},
function finish(err, nodeStatus, stats) {
LayergroupController.prototype.analysisNodeStatus = function (analysisStatusBackend) {
return function analysisNodeStatusMiddleware(req, res, next) {
analysisStatusBackend.getNodeStatus(res.locals, (err, nodeStatus, stats) => {
req.profiler.add(stats || {});
if (err) {
err.label = 'GET NODE STATUS';
next(err);
} else {
self.sendResponse(req, res, nodeStatus, 200, {
'Cache-Control': 'public,max-age=5',
'Last-Modified': new Date().toUTCString()
});
return next(err);
}
}
);
this.sendResponse(req, res, nodeStatus, 200, {
'Cache-Control': 'public,max-age=5',
'Last-Modified': new Date().toUTCString()
});
});
}.bind(this);
};
LayergroupController.prototype.getMapStoreMapConfigProvider = function (mapStore, userLimitsApi) {