Initial Mebbling hub implementation

This commit is contained in:
2026-07-19 00:29:30 +08:00
commit e6ebdb0576
41 changed files with 2571 additions and 0 deletions
+8
View File
@@ -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;
}