From 4cba4c7a1f0cb4d0fd36cc18e61c776f455c6043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Fri, 23 Mar 2018 17:37:06 +0100 Subject: [PATCH] Tidy middlewares up: cleanUpQeuryParams --- lib/cartodb/controllers/analyses.js | 2 +- lib/cartodb/controllers/layergroup.js | 22 +++++++++++----------- lib/cartodb/controllers/map.js | 2 +- lib/cartodb/controllers/named_maps.js | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/cartodb/controllers/analyses.js b/lib/cartodb/controllers/analyses.js index 9a48e30f..9ed6e092 100644 --- a/lib/cartodb/controllers/analyses.js +++ b/lib/cartodb/controllers/analyses.js @@ -25,12 +25,12 @@ AnalysesController.prototype.register = function (app) { app.get( `${mapconfigBasePath}/analyses/catalog`, cors(), - cleanUpQueryParams(), user(), rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.ANALYSIS_CATALOG), credentials(), authorize(this.authApi), dbConnSetup(this.pgConnection), + cleanUpQueryParams(), createPGClient(), getDataFromQuery({ queryTemplate: catalogQueryTpl, key: 'catalog' }), getDataFromQuery({ queryTemplate: tablesQueryTpl, key: 'tables' }), diff --git a/lib/cartodb/controllers/layergroup.js b/lib/cartodb/controllers/layergroup.js index da9189ef..fa07f73e 100644 --- a/lib/cartodb/controllers/layergroup.js +++ b/lib/cartodb/controllers/layergroup.js @@ -89,13 +89,13 @@ LayergroupController.prototype.register = function(app) { app.get( `${mapConfigBasePath}/:token/:z/:x/:y@:scale_factor?x.:format`, cors(), - cleanUpQueryParams(), user(), rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.TILE), layergroupToken(), credentials(), authorize(this.authApi), dbConnSetup(this.pgConnection), + cleanUpQueryParams(), createMapStoreMapConfigProvider( this.mapStore, this.userLimitsApi, @@ -117,13 +117,13 @@ LayergroupController.prototype.register = function(app) { app.get( `${mapConfigBasePath}/:token/:z/:x/:y.:format`, cors(), - cleanUpQueryParams(), user(), rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.TILE), layergroupToken(), credentials(), authorize(this.authApi), dbConnSetup(this.pgConnection), + cleanUpQueryParams(), createMapStoreMapConfigProvider( this.mapStore, this.userLimitsApi, @@ -146,13 +146,13 @@ LayergroupController.prototype.register = function(app) { `${mapConfigBasePath}/:token/:layer/:z/:x/:y.(:format)`, distinguishLayergroupFromStaticRoute(), cors(), - cleanUpQueryParams(), user(), rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.TILE), layergroupToken(), credentials(), authorize(this.authApi), dbConnSetup(this.pgConnection), + cleanUpQueryParams(), createMapStoreMapConfigProvider( this.mapStore, this.userLimitsApi, @@ -174,13 +174,13 @@ LayergroupController.prototype.register = function(app) { app.get( `${mapConfigBasePath}/:token/:layer/attributes/:fid`, cors(), - cleanUpQueryParams(), user(), rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.ATTRIBUTES), layergroupToken(), credentials(), authorize(this.authApi), dbConnSetup(this.pgConnection), + cleanUpQueryParams(), createMapStoreMapConfigProvider( this.mapStore, this.userLimitsApi, @@ -200,13 +200,13 @@ LayergroupController.prototype.register = function(app) { app.get( `${mapConfigBasePath}/static/center/:token/:z/:lat/:lng/:width/:height.:format`, cors(), - cleanUpQueryParams(['layer']), user(), rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.STATIC), layergroupToken(), credentials(), authorize(this.authApi), dbConnSetup(this.pgConnection), + cleanUpQueryParams(['layer']), createMapStoreMapConfigProvider( this.mapStore, this.userLimitsApi, @@ -225,13 +225,13 @@ LayergroupController.prototype.register = function(app) { app.get( `${mapConfigBasePath}/static/bbox/:token/:west,:south,:east,:north/:width/:height.:format`, cors(), - cleanUpQueryParams(['layer']), user(), rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.STATIC), layergroupToken(), credentials(), authorize(this.authApi), dbConnSetup(this.pgConnection), + cleanUpQueryParams(['layer']), createMapStoreMapConfigProvider( this.mapStore, this.userLimitsApi, @@ -253,13 +253,13 @@ LayergroupController.prototype.register = function(app) { app.get( `${mapConfigBasePath}/:token/dataview/:dataviewName`, cors(), - cleanUpQueryParams(ALLOWED_DATAVIEW_QUERY_PARAMS), user(), rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.DATAVIEW), layergroupToken(), credentials(), authorize(this.authApi), dbConnSetup(this.pgConnection), + cleanUpQueryParams(ALLOWED_DATAVIEW_QUERY_PARAMS), createMapStoreMapConfigProvider( this.mapStore, this.userLimitsApi, @@ -277,13 +277,13 @@ LayergroupController.prototype.register = function(app) { app.get( `${mapConfigBasePath}/:token/:layer/widget/:dataviewName`, cors(), - cleanUpQueryParams(ALLOWED_DATAVIEW_QUERY_PARAMS), user(), rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.DATAVIEW), layergroupToken(), credentials(), authorize(this.authApi), dbConnSetup(this.pgConnection), + cleanUpQueryParams(ALLOWED_DATAVIEW_QUERY_PARAMS), createMapStoreMapConfigProvider( this.mapStore, this.userLimitsApi, @@ -301,13 +301,13 @@ LayergroupController.prototype.register = function(app) { app.get( `${mapConfigBasePath}/:token/dataview/:dataviewName/search`, cors(), - cleanUpQueryParams(ALLOWED_DATAVIEW_QUERY_PARAMS), user(), rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.DATAVIEW_SEARCH), layergroupToken(), credentials(), authorize(this.authApi), dbConnSetup(this.pgConnection), + cleanUpQueryParams(ALLOWED_DATAVIEW_QUERY_PARAMS), createMapStoreMapConfigProvider( this.mapStore, this.userLimitsApi, @@ -325,13 +325,13 @@ LayergroupController.prototype.register = function(app) { app.get( `${mapConfigBasePath}/:token/:layer/widget/:dataviewName/search`, cors(), - cleanUpQueryParams(ALLOWED_DATAVIEW_QUERY_PARAMS), user(), rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.DATAVIEW_SEARCH), layergroupToken(), credentials(), authorize(this.authApi), dbConnSetup(this.pgConnection), + cleanUpQueryParams(ALLOWED_DATAVIEW_QUERY_PARAMS), createMapStoreMapConfigProvider( this.mapStore, this.userLimitsApi, @@ -349,13 +349,13 @@ LayergroupController.prototype.register = function(app) { app.get( `${mapConfigBasePath}/:token/analysis/node/:nodeId`, cors(), - cleanUpQueryParams(), user(), rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.ANALYSIS), layergroupToken(), credentials(), authorize(this.authApi), dbConnSetup(this.pgConnection), + cleanUpQueryParams(), analysisNodeStatus(this.analysisStatusBackend), sendResponse() ); diff --git a/lib/cartodb/controllers/map.js b/lib/cartodb/controllers/map.js index 0ec3a160..5aea9273 100644 --- a/lib/cartodb/controllers/map.js +++ b/lib/cartodb/controllers/map.js @@ -100,12 +100,12 @@ MapController.prototype.composeCreateMapMiddleware = function (endpointGroup, us return [ cors(), - cleanUpQueryParams(['aggregation']), user(), rateLimit(this.userLimitsApi, endpointGroup), credentials(), authorize(this.authApi), dbConnSetup(this.pgConnection), + cleanUpQueryParams(['aggregation']), initProfiler(isTemplateInstantiation), checkJsonContentType(), this.getCreateMapMiddlewares(useTemplate), diff --git a/lib/cartodb/controllers/named_maps.js b/lib/cartodb/controllers/named_maps.js index f00acb8e..37794c6a 100644 --- a/lib/cartodb/controllers/named_maps.js +++ b/lib/cartodb/controllers/named_maps.js @@ -55,12 +55,12 @@ NamedMapsController.prototype.register = function(app) { app.get( `${templateBasePath}/:template_id/:layer/:z/:x/:y.(:format)`, cors(), - cleanUpQueryParams(), user(), rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.NAMED_TILES), credentials(), authorize(this.authApi), dbConnSetup(this.pgConnection), + cleanUpQueryParams(), getNamedMapProvider({ namedMapProviderCache: this.namedMapProviderCache, label: 'NAMED_MAP_TILE' @@ -81,12 +81,12 @@ NamedMapsController.prototype.register = function(app) { app.get( `${mapconfigBasePath}/static/named/:template_id/:width/:height.:format`, cors(), - cleanUpQueryParams(['layer', 'zoom', 'lon', 'lat', 'bbox']), user(), rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.STATIC_NAMED), credentials(), authorize(this.authApi), dbConnSetup(this.pgConnection), + cleanUpQueryParams(['layer', 'zoom', 'lon', 'lat', 'bbox']), getNamedMapProvider({ namedMapProviderCache: this.namedMapProviderCache, label: 'STATIC_VIZ_MAP', forcedFormat: 'png'