(repoKey, now = Date.now())
| 90 | } |
| 91 | |
| 92 | function checkRepoCooldown(repoKey, now = Date.now()) { |
| 93 | cleanupExpiredEntries(now); |
| 94 | const { cooldownMs } = getRepoProtectionConfig(); |
| 95 | |
| 96 | const nextAllowedAt = repoCooldowns.get(repoKey); |
| 97 | if (!nextAllowedAt || now >= nextAllowedAt) { |
| 98 | return { allowed: true, retryAfterSeconds: 0 }; |
| 99 | } |
| 100 | |
| 101 | const retryAfterSeconds = Math.max(1, Math.ceil((nextAllowedAt - now) / 1000)); |
| 102 | return { allowed: false, retryAfterSeconds, cooldownMs }; |
| 103 | } |
| 104 | |
| 105 | function setRepoCooldown(repoKey, now = Date.now()) { |
| 106 | const { cooldownMs } = getRepoProtectionConfig(); |
no test coverage detected