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

Function cleanupExpiredEntries

website/api/lib/security.js:43–64  ·  view source on GitHub ↗
(now = Date.now())

Source from the content-addressed store, hash-verified

41}
42
43function cleanupExpiredEntries(now = Date.now()) {
44 const { windowMs } = getRateLimitConfig();
45 const { cooldownMs, activeJobTtlMs } = getRepoProtectionConfig();
46
47 for (const [ip, entry] of ipRateLimits.entries()) {
48 if (now - entry.windowStart >= windowMs) {
49 ipRateLimits.delete(ip);
50 }
51 }
52
53 for (const [repo, nextAllowedAt] of repoCooldowns.entries()) {
54 if (now >= nextAllowedAt + cooldownMs) {
55 repoCooldowns.delete(repo);
56 }
57 }
58
59 for (const [repo, job] of activeRepoJobs.entries()) {
60 if (now - job.startedAt >= activeJobTtlMs) {
61 activeRepoJobs.delete(repo);
62 }
63 }
64}
65
66function checkRateLimit(ip, now = Date.now()) {
67 cleanupExpiredEntries(now);

Callers 3

checkRateLimitFunction · 0.85
checkRepoCooldownFunction · 0.85
getActiveRepoJobFunction · 0.85

Calls 3

getRateLimitConfigFunction · 0.85
getRepoProtectionConfigFunction · 0.85
deleteMethod · 0.65

Tested by

no test coverage detected