diff options
| author | Ritesh Ghosh <[email protected]> | 2024-02-28 23:54:18 +0530 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-02-28 23:54:18 +0530 |
| commit | 55d1d43fecbe22ddaf20d849060afbec58cb2bc2 (patch) | |
| tree | b812110b82635eed5c24c75aa981135d91ce2da9 | |
| parent | 10ab4ad9ebfbe24a0c2b524517a922524fe91e86 (diff) | |
| parent | 3dc9d80d4402d1af511bdd7c4e1acb79068bfc6b (diff) | |
| download | aniwatch-api-55d1d43fecbe22ddaf20d849060afbec58cb2bc2.tar.xz aniwatch-api-55d1d43fecbe22ddaf20d849060afbec58cb2bc2.zip | |
Merge pull request #25 from ayushch80/main
Added `.env.example`
| -rw-r--r-- | .env.example | 6 | ||||
| -rw-r--r-- | src/config/ratelimit.ts | 6 | ||||
| -rw-r--r-- | src/utils/constants.ts | 7 |
3 files changed, 16 insertions, 3 deletions
diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..6829a4e --- /dev/null +++ b/.env.example @@ -0,0 +1,6 @@ +DOMAIN = "aniwatchtv.to" +PORT = 4000 + +# RATE LIMIT +WINDOWMS = 1800000 # duration to track requests (in milliseconds) for rate limiting. here, 30*60*1000 = 1800000 = 30 minutes +MAX = 70 # maximum number of requests in this timeperiod
\ No newline at end of file diff --git a/src/config/ratelimit.ts b/src/config/ratelimit.ts index 9bf70c2..75cb1f8 100644 --- a/src/config/ratelimit.ts +++ b/src/config/ratelimit.ts @@ -1,8 +1,10 @@ import { rateLimit } from "express-rate-limit"; +import { config } from "dotenv"; +config(); export const ratelimit = rateLimit({ - windowMs: 30 * 60 * 1000, - max: 70, + windowMs: Number(process.env.WINDOWMS) || 30 * 60 * 1000, + max: Number(process.env.MAX) || 70, legacyHeaders: true, standardHeaders: "draft-7", message: "Too many API requests, try again later", diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 0813a5d..ee49d35 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -1,3 +1,6 @@ +import { config } from "dotenv"; +config(); + export const ACCEPT_ENCODING_HEADER = "gzip, deflate, br"; export const USER_AGENT_HEADER = @@ -6,7 +9,9 @@ export const USER_AGENT_HEADER = export const ACCEPT_HEADER = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"; -export const SRC_BASE_URL = "https://aniwatchtv.to"; +const DOMAIN = process.env.DOMAIN || "aniwatchtv.to" + +export const SRC_BASE_URL = `https://${DOMAIN}`; export const SRC_AJAX_URL = `${SRC_BASE_URL}/ajax`; export const SRC_HOME_URL = `${SRC_BASE_URL}/home`; export const SRC_SEARCH_URL = `${SRC_BASE_URL}/search`; |
