Pass dataview-backend as middleware option

This commit is contained in:
Daniel García Aubert 2018-03-05 18:04:50 +01:00
parent 5e43a7145a
commit acb9ce33b1

View File

@ -125,7 +125,7 @@ LayergroupController.prototype.register = function(app) {
allowQueryParams(allowedDataviewQueryParams),
this.prepareContext,
this.getMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi),
this.getDataview()
this.getDataview(this.dataviewBackend)
);
app.get(
@ -135,7 +135,7 @@ LayergroupController.prototype.register = function(app) {
allowQueryParams(allowedDataviewQueryParams),
this.prepareContext,
this.getMapStoreMapConfigProvider(this.mapStore, this.userLimitsApi),
this.getDataview()
this.getDataview(this.dataviewBackend)
);
app.get(
@ -198,11 +198,11 @@ LayergroupController.prototype.getMapStoreMapConfigProvider = function (mapStore
};
};
LayergroupController.prototype.getDataview = function () {
LayergroupController.prototype.getDataview = function (dataviewBackend) {
return function getDataviewMiddleware (req, res, next) {
const { user, mapConfigProvider } = res.locals;
this.dataviewBackend.getDataview(mapConfigProvider, user, res.locals, (err, dataview, stats) => {
dataviewBackend.getDataview(mapConfigProvider, user, res.locals, (err, dataview, stats) => {
req.profiler.add(stats || {});
if (err) {