Initial SeConectai briefing system

This commit is contained in:
2026-10-04 10:42:23 -03:00
commit 45cd8d2f03
163 changed files with 12659 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
type Bucket = {
count: number;
resetAt: number;
};
const buckets = new Map<string, Bucket>();
export function checkRateLimit(key: string, limit = 5, windowMs = 15 * 60 * 1000) {
const now = Date.now();
const bucket = buckets.get(key);
if (!bucket || bucket.resetAt <= now) {
buckets.set(key, { count: 1, resetAt: now + windowMs });
return { allowed: true, remaining: limit - 1 };
}
if (bucket.count >= limit) {
return { allowed: false, remaining: 0 };
}
bucket.count += 1;
return { allowed: true, remaining: limit - bucket.count };
}