@da440dil/js-counter
Version:
Distributed rate limiting using Redis
15 lines (14 loc) • 390 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Limiter = void 0;
class Limiter {
constructor(counter, prefix, rate) {
this.counter = counter;
this.prefix = prefix;
this.rate = rate;
}
limit(key) {
return this.counter.count(`${this.prefix}${key}`, this.rate);
}
}
exports.Limiter = Limiter;