(maxPerHour: number)
| 19 | private readonly maxPerHour: number; |
| 20 | |
| 21 | constructor(maxPerHour: number) { |
| 22 | this.maxPerHour = maxPerHour; |
| 23 | setInterval(() => this.cleanup(), 5 * 60_000).unref(); |
| 24 | } |
| 25 | |
| 26 | allow(userId: string): boolean { |
| 27 | return this.recent(userId).length < this.maxPerHour; |