restructures project for maintainability

This commit is contained in:
Sampson committed 2025-06-18 12:18:22 -05:00
1 parent 62cd97c5a0
commit 486d4f06f5
6 files changed
+295 -285

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
import { RATE_LIMIT } from "./constants.js";
let requestCount = {
second: 0,
month: 0,
lastReset: Date.now()
};
export function checkRateLimit() {
const now = Date.now();
if (now - requestCount.lastReset > 1000) {
requestCount.second = 0;
requestCount.lastReset = now;
}
if (requestCount.second >= RATE_LIMIT.perSecond ||
requestCount.month >= RATE_LIMIT.perMonth) {
throw new Error('Rate limit exceeded');
}
requestCount.second++;
requestCount.month++;
}