aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRitesh Ghosh <[email protected]>2024-03-03 20:04:22 +0530
committerRitesh Ghosh <[email protected]>2024-03-03 20:04:22 +0530
commiteea621b17a14363b003382ea237cd43361bc5df9 (patch)
tree68cc67df7709baa3ff4ab938d9136b95cce08f43
parent5562885184e892743f14df199a21d9521deeb989 (diff)
parentd779537275ebd9395189f9178b0422ad0439851f (diff)
downloadaniwatch-api-eea621b17a14363b003382ea237cd43361bc5df9.tar.xz
aniwatch-api-eea621b17a14363b003382ea237cd43361bc5df9.zip
feat: merge 'main' of https://github.com/ghoshRitesh12/aniwatch-api
-rw-r--r--.env.example6
-rw-r--r--CHANGELOG.md8
-rw-r--r--package.json2
-rw-r--r--src/config/ratelimit.ts6
-rw-r--r--src/utils/constants.ts8
5 files changed, 21 insertions, 9 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/CHANGELOG.md b/CHANGELOG.md
index c742b84..bc9e541 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## [1.24.1](https://github.com/ghoshRitesh12/aniwatch-api/compare/v1.24.0...v1.24.1) (2024-02-28)
+
+
+
# [1.24.0](https://github.com/ghoshRitesh12/aniwatch-api/compare/v1.23.0...v1.24.0) (2024-02-25)
@@ -31,7 +35,3 @@
-## [1.21.3](https://github.com/ghoshRitesh12/aniwatch-api/compare/v1.21.2...v1.21.3) (2024-01-07)
-
-
-
diff --git a/package.json b/package.json
index 9077b22..16180af 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "aniwatch-api",
- "version": "1.24.0",
+ "version": "1.24.1",
"description": "Node Express API for obtaining anime information from aniwatch",
"main": "ts-node src/server.ts",
"type": "module",
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 0d95751..08499ee 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,8 +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";
-// previously aniwatch.to || aniwatchtv.to
-export const SRC_BASE_URL = "https://hianime.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`;