Extract layergroup data augmentation to its own "middleware"

This commit is contained in:
Daniel García Aubert
2017-10-31 13:46:03 +01:00
parent 48172d4dc1
commit 3cf4a8f70b
+16 -6
View File
@@ -332,11 +332,6 @@ MapController.prototype.afterLayergroupCreate = function (req, res, callback) {
}
};
// include in layergroup response the variables in serverMedata
// those variables are useful to send to the client information
// about how to reach this server or information about it
_.extend(layergroup, global.environment.serverMetadata);
// Don't wait for the mapview count increment to
// take place before proceeding. Error will be logged
// asynchronously
@@ -349,7 +344,11 @@ MapController.prototype.afterLayergroupCreate = function (req, res, callback) {
});
step(
function getAffectedTables () {
function () {
self.augmentLayergroupData(req, res, this);
},
function getAffectedTables (err) {
assert.ifError(err);
self.getAffectedTables(req, res, this);
},
function setCacheChannel (err) {
@@ -374,6 +373,17 @@ MapController.prototype.afterLayergroupCreate = function (req, res, callback) {
);
};
MapController.prototype.augmentLayergroupData = function (req, res, callback) {
const { layergroup } = res.locals;
// include in layergroup response the variables in serverMedata
// those variables are useful to send to the client information
// about how to reach this server or information about it
_.extend(layergroup, global.environment.serverMetadata);
callback();
}
MapController.prototype.getAffectedTables = function (req, res, callback) {
const self = this;
const { dbname, layergroup, user, mapconfig } = res.locals;