CartoDB-SQL-API/lib/services/user-limits.js

28 lines
621 B
JavaScript
Raw Normal View History

2018-10-24 21:42:33 +08:00
'use strict';
2018-03-01 18:30:34 +08:00
/**
* UserLimits
2018-10-24 21:42:33 +08:00
* @param {cartodb-redis} metadataBackend
* @param {object} options
2018-03-01 18:30:34 +08:00
*/
class UserLimits {
2019-12-24 01:19:08 +08:00
constructor (metadataBackend, options = {}) {
2018-03-01 18:30:34 +08:00
this.metadataBackend = metadataBackend;
this.options = options;
2018-03-01 22:51:19 +08:00
this.preprareRateLimit();
2018-03-01 18:30:34 +08:00
}
2019-12-24 01:19:08 +08:00
preprareRateLimit () {
2018-03-01 18:30:34 +08:00
if (this.options.limits.rateLimitsEnabled) {
2018-03-03 22:01:45 +08:00
this.metadataBackend.loadRateLimitsScript();
2018-03-01 18:30:34 +08:00
}
}
2019-12-24 01:19:08 +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;