Initial Mebbling hub implementation
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
const visits = new Map<string, { count: number; resetAt: number }>();
|
||||
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user