Fixed Themes not showing

This commit is contained in:
JCBSComputer
2026-06-30 16:48:59 +02:00
parent feb2549373
commit 4eba6fe476
7 changed files with 112 additions and 7 deletions
+31
View File
@@ -0,0 +1,31 @@
const attempts = new Map<string, { count: number; resetAt: number }>()
export function checkRateLimit(
key: string,
maxAttempts = 5,
windowMs = 60000,
): { allowed: boolean; remaining: number; resetAt: number } {
const now = Date.now()
const entry = attempts.get(key)
if (!entry || now > entry.resetAt) {
attempts.set(key, { count: 1, resetAt: now + windowMs })
return { allowed: true, remaining: maxAttempts - 1, resetAt: now + windowMs }
}
entry.count++
if (entry.count > maxAttempts) {
return { allowed: false, remaining: 0, resetAt: entry.resetAt }
}
return { allowed: true, remaining: maxAttempts - entry.count, resetAt: entry.resetAt }
}
// Cleanup stale entries every 5 minutes
setInterval(() => {
const now = Date.now()
for (const [key, entry] of attempts) {
if (now > entry.resetAt) attempts.delete(key)
}
}, 300000)