MCPcopy Index your code
hub / github.com/CodeGraphContext/CodeGraphContext / checkRepoCooldown

Function checkRepoCooldown

website/api/lib/security.js:92–103  ·  view source on GitHub ↗
(repoKey, now = Date.now())

Source from the content-addressed store, hash-verified

90}
91
92function 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
105function setRepoCooldown(repoKey, now = Date.now()) {
106 const { cooldownMs } = getRepoProtectionConfig();

Callers 1

handlerFunction · 0.90

Calls 3

cleanupExpiredEntriesFunction · 0.85
getRepoProtectionConfigFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected