AI Implementation feature(873): Landing Page and Login/Register Modal 1.01 (#13)
This commit was merged in pull request #13.
This commit is contained in:
@@ -18,4 +18,15 @@ export class RegistrationRateLimitService {
|
||||
arr.push(now);
|
||||
this.hits.set(ip, arr);
|
||||
}
|
||||
}
|
||||
|
||||
tryConsume(ip: string, now: number = Date.now()): boolean {
|
||||
const arr = (this.hits.get(ip) ?? []).filter((t) => now - t < WINDOW_MS);
|
||||
if (arr.length >= MAX_PER_WINDOW) {
|
||||
this.hits.set(ip, arr);
|
||||
return false;
|
||||
}
|
||||
arr.push(now);
|
||||
this.hits.set(ip, arr);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user