default rate limits params to server.js

This commit is contained in:
Simon Martín 2018-05-11 15:41:35 +02:00
parent d70013b0f4
commit 60b48df4d6
2 changed files with 13 additions and 17 deletions

View File

@ -66,6 +66,19 @@ function App(statsClient) {
// Set default configuration
global.settings.db_pubuser = global.settings.db_pubuser || "publicuser";
global.settings.bufferedRows = global.settings.bufferedRows || 1000;
global.settings.ratelimits = Object.assign(
{
rateLimitsEnabled: false,
endpoints: {
query: false,
query_format: false,
job_create: false,
job_get: false,
job_delete: false
}
},
global.settings.ratelimits
);
var tableCache = new TableCacheFactory().build(global.settings);
@ -137,7 +150,6 @@ function App(statsClient) {
var userDatabaseService = new UserDatabaseService(metadataBackend);
UserLimitsService.configure();
const userLimitsServiceOptions = {
limits: {
rateLimitsEnabled: global.settings.ratelimits.rateLimitsEnabled

View File

@ -1,14 +1,3 @@
const DEFAULT_RATE_LIMITS_OPTIONS = {
rateLimitsEnabled: false,
endpoints: {
query: false,
query_format: false,
job_create: false,
job_get: false,
job_delete: false
}
};
/**
* UserLimits
* @param {cartodb-redis} metadataBackend
@ -22,11 +11,6 @@ class UserLimits {
this.preprareRateLimit();
}
static configure() {
// default rate limits
global.settings.ratelimits = Object.assign({}, DEFAULT_RATE_LIMITS_OPTIONS, global.settings.ratelimits);
}
preprareRateLimit() {
if (this.options.limits.rateLimitsEnabled) {
this.metadataBackend.loadRateLimitsScript();