diff --git a/config/environments/development.js.example b/config/environments/development.js.example index 35a9faaf..12de0912 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -354,6 +354,7 @@ var config = { dataview: false, dataview_search: false, analysis: false, + analysis_catalog: false, tile: false, attributes: false, named_list: false, diff --git a/config/environments/production.js.example b/config/environments/production.js.example index f4299e3a..beb9f15c 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -356,6 +356,7 @@ var config = { dataview: false, dataview_search: false, analysis: false, + analysis_catalog: false, tile: false, attributes: false, named_list: false, diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index b4ef62bf..40d3bb8b 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -356,6 +356,7 @@ var config = { dataview: false, dataview_search: false, analysis: false, + analysis_catalog: false, tile: false, attributes: false, named_list: false, diff --git a/config/environments/test.js.example b/config/environments/test.js.example index b2fe3360..4d2c2d27 100644 --- a/config/environments/test.js.example +++ b/config/environments/test.js.example @@ -350,6 +350,7 @@ var config = { dataview: false, dataview_search: false, analysis: false, + analysis_catalog: false, tile: false, attributes: false, named_list: false, diff --git a/lib/cartodb/controllers/analyses.js b/lib/cartodb/controllers/analyses.js index db3550c8..2e057501 100644 --- a/lib/cartodb/controllers/analyses.js +++ b/lib/cartodb/controllers/analyses.js @@ -1,9 +1,12 @@ var PSQL = require('cartodb-psql'); var cors = require('../middleware/cors'); var userMiddleware = require('../middleware/user'); +const rateLimit = require('../middleware/rate-limit'); +const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimit; -function AnalysesController(prepareContext) { +function AnalysesController(prepareContext, userLimitsApi) { this.prepareContext = prepareContext; + this.userLimitsApi = userLimitsApi; } module.exports = AnalysesController; @@ -14,6 +17,7 @@ AnalysesController.prototype.register = function (app) { cors(), userMiddleware(), this.prepareContext, + rateLimit(this.userLimitsApi, RATE_LIMIT_ENDPOINTS_GROUPS.ANALYSIS_CATALOG), this.createPGClient(), this.getDataFromQuery({ queryTemplate: catalogQueryTpl, key: 'catalog' }), this.getDataFromQuery({ queryTemplate: tablesQueryTpl, key: 'tables' }), diff --git a/lib/cartodb/middleware/rate-limit.js b/lib/cartodb/middleware/rate-limit.js index c864a821..9a3daa9b 100644 --- a/lib/cartodb/middleware/rate-limit.js +++ b/lib/cartodb/middleware/rate-limit.js @@ -7,6 +7,7 @@ const RATE_LIMIT_ENDPOINTS_GROUPS = { DATAVIEW: 'dataview', DATAVIEW_SEARCH: 'dataview_search', ANALYSIS: 'analysis', + ANALYSIS_CATALOG: 'analysis_catalog', TILE: 'tile', ATTRIBUTES: 'attributes', NAMED_LIST: 'named_list', diff --git a/lib/cartodb/server.js b/lib/cartodb/server.js index 51dc53d1..27b0178f 100644 --- a/lib/cartodb/server.js +++ b/lib/cartodb/server.js @@ -263,7 +263,7 @@ module.exports = function(serverOptions) { new controller.NamedMapsAdmin(authApi, templateMaps, userLimitsApi).register(app); - new controller.Analyses(prepareContext).register(app); + new controller.Analyses(prepareContext, userLimitsApi).register(app); new controller.ServerInfo(versions).register(app);