feat: Upstash implementation for rate limiting/redis (#9514)

* Introduce rate limiting that works on the edge

* typo

* Log once on init

* Update rateLimit.ts

---------

Co-authored-by: zomars <[email protected]>
This commit is contained in:
sean-brydonandzomars authored and GitHub committed 2023-06-19 10:01:06 +00:00
1 parent ed65b2a3ab
commit 8eccd3658e
9 files changed
+124 -44

No files matched your search

+10
View File
@@ -28,3 +28,13 @@ export function isIpInBanlist(request: Request | NextApiRequest) {
}
return false;
}
export function isIpInBanListString(identifer: string) {
const rawBanListJson = process.env.IP_BANLIST || "[]";
const banList = banlistSchema.parse(JSON.parse(rawBanListJson));
if (banList.includes(identifer)) {
console.log(`Found banned IP: ${identifer} in IP_BANLIST`);
return true;
}
return false;
}