refactor(rest): separate functions into diff files (#685)

* shtufffff

* fixe rate limit path infinite loop

* refactor

* ID > id

* Update process_request_headers.ts

* file names

Co-authored-by: ITOH <72305210+itohatweb@users.noreply.github.com>
Co-authored-by: ayntee <ayyantee@gmail.com>
This commit is contained in:
Skillz4Killz
2021-03-29 15:50:08 -04:00
committed by GitHub
parent 79d57f0377
commit ebb15afa0e
16 changed files with 444 additions and 708 deletions
+17
View File
@@ -0,0 +1,17 @@
import { rest } from "./rest.ts";
/** Check the rate limits for a url or a bucket. */
export function checkRateLimits(url: string) {
const ratelimited = rest.ratelimitedPaths.get(url);
const global = rest.ratelimitedPaths.get("global");
const now = Date.now();
if (ratelimited && now < ratelimited.resetTimestamp) {
return ratelimited.resetTimestamp - now;
}
if (global && now < global.resetTimestamp) {
return global.resetTimestamp - now;
}
return false;
}