rate limit analysis catalog endpoint

This commit is contained in:
Simon Martín 2018-03-14 17:46:19 +01:00
parent cbfeb0158e
commit 48a7d28aa6
7 changed files with 11 additions and 2 deletions

View File

@ -354,6 +354,7 @@ var config = {
dataview: false,
dataview_search: false,
analysis: false,
analysis_catalog: false,
tile: false,
attributes: false,
named_list: false,

View File

@ -356,6 +356,7 @@ var config = {
dataview: false,
dataview_search: false,
analysis: false,
analysis_catalog: false,
tile: false,
attributes: false,
named_list: false,

View File

@ -356,6 +356,7 @@ var config = {
dataview: false,
dataview_search: false,
analysis: false,
analysis_catalog: false,
tile: false,
attributes: false,
named_list: false,

View File

@ -350,6 +350,7 @@ var config = {
dataview: false,
dataview_search: false,
analysis: false,
analysis_catalog: false,
tile: false,
attributes: false,
named_list: false,

View File

@ -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' }),

View File

@ -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',

View File

@ -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);