Pass only needed params to create layergroup map config provider

This commit is contained in:
Daniel García Aubert 2018-03-22 19:36:42 +01:00
parent 6b7c2675f1
commit d029f81992

View File

@ -319,16 +319,26 @@ function prepareAdapterMapConfig (mapConfigAdapter) {
function createLayergroup (mapBackend, userLimitsApi, pgConnection, affectedTablesCache) { function createLayergroup (mapBackend, userLimitsApi, pgConnection, affectedTablesCache) {
return function createLayergroupMiddleware (req, res, next) { return function createLayergroupMiddleware (req, res, next) {
const requestMapConfig = req.body; const requestMapConfig = req.body;
const { context, user } = res.locals;
const { context } = res.locals;
const { user, cache_buster, api_key } = res.locals;
const { dbuser, dbname, dbpassword, dbhost, dbport } = res.locals;
const params = {
cache_buster, api_key,
dbuser, dbname, dbpassword, dbhost, dbport
};
const datasource = context.datasource || Datasource.EmptyDatasource(); const datasource = context.datasource || Datasource.EmptyDatasource();
const mapConfig = new MapConfig(requestMapConfig, datasource); const mapConfig = new MapConfig(requestMapConfig, datasource);
const mapConfigProvider = new CreateLayergroupMapConfigProvider( const mapConfigProvider = new CreateLayergroupMapConfigProvider(
mapConfig, mapConfig,
user, user,
userLimitsApi, userLimitsApi,
pgConnection, pgConnection,
affectedTablesCache, affectedTablesCache,
res.locals params
); );
res.locals.mapConfig = mapConfig; res.locals.mapConfig = mapConfig;