CartoDB-SQL-API/app/services/user_limits.js

26 lines
605 B
JavaScript
Raw Normal View History

2018-03-01 18:30:34 +08:00
/**
* UserLimits
* @param {cartodb-redis} metadataBackend
* @param {object} options
*/
class UserLimits {
constructor(metadataBackend, options = {}) {
this.metadataBackend = metadataBackend;
this.options = options;
2018-03-01 22:51:19 +08:00
this.preprareRateLimit();
2018-03-01 18:30:34 +08:00
}
preprareRateLimit() {
if (this.options.limits.rateLimitsEnabled) {
2018-03-03 22:01:45 +08:00
this.metadataBackend.loadRateLimitsScript();
2018-03-01 18:30:34 +08:00
}
}
getRateLimit(user, endpointGroup, callback) {
2018-03-03 22:01:45 +08:00
this.metadataBackend.getRateLimit(user, 'sql', endpointGroup, callback);
2018-03-01 21:47:34 +08:00
}
}
2018-03-01 18:30:34 +08:00
module.exports = UserLimits;