const visits = new Map(); export function withinRateLimit(key: string, limit = 30, windowMs = 60_000) { const now = Date.now(); const record = visits.get(key); if (!record || record.resetAt <= now) { visits.set(key, { count: 1, resetAt: now + windowMs }); return true; } if (record.count >= limit) return false; record.count += 1; return true; }