fix: Full diagnostic sweep — bugs, dead code, unused imports, docs accuracy

Code fixes:
- seasons/watchOrder: Remove dead ternary (both branches identical)
- mirror.helper: Remove redundant ternary (both branches identical)
- topAnimeRankings: Fix JSDoc (day/week/month, not top/newest)
- apiRoutes: Fix proxy domain validation (exact match, not includes)
- apiRoutes: Fix proxy .m3u8 check (pathname, not hostname)
- pagination: Fix totalItems calculation (was overestimating)
- server.js: Remove dead has404File variable
- server.js: Remove duplicate /api/cache/stats route
- server.js: Remove unused getCacheStats import

Unused imports removed:
- animeInfo: URLS from dataUrl.js
- episodeList: headers from header.config.js
- episodeListAjax: axios
- trending: URLS from dataUrl.js
- trendingSidebar: URLS from dataUrl.js
- upcomingAnime: parseListItems
- watchPage: URLS, BASE_URL from dataUrl.js

Docs fixes:
- README: 33->38 endpoints, 24->28 controllers, 26->28 extractors
- README: Cache TTL 5min->per-endpoint, Timeout 15s->30s
- docs/index.md: 33->38 endpoints
- architecture.md: LRU cache strategy, remove stale cookie-parser
- agents: compression version, extractor/controller counts
- agents: domain typo, stale CORS dep, version badge
This commit is contained in:
Shinei Nouzen
2026-07-30 00:50:18 +05:30
parent 715add099b
commit 996cead3b1
21 changed files with 24 additions and 40 deletions
-1
View File
@@ -17,7 +17,6 @@
*/
import * as cheerio from "cheerio";
import { URLS } from "../configs/dataUrl.js";
import { fetchWithMirror } from "../helper/mirror.helper.js";
// ══════════════════════════════════════════════════════════════
-2
View File
@@ -17,8 +17,6 @@
*/
import * as cheerio from "cheerio";
import { headers } from "../configs/header.config.js";
import { URLS, BASE_URL } from "../configs/dataUrl.js";
import { fetchWithMirror } from "../helper/mirror.helper.js";
// ══════════════════════════════════════════════════════════════
@@ -17,7 +17,6 @@
*/
import * as cheerio from "cheerio";
import axios from "axios";
import { headers } from "../configs/header.config.js";
import { fetchWithMirror } from "../helper/mirror.helper.js";
+1 -1
View File
@@ -40,7 +40,7 @@ import { fetchWithMirror } from "../helper/mirror.helper.js";
*/
const extractSeasons = async (slugOrId) => {
try {
const path = /^\d+$/.test(slugOrId) ? `/watch/${slugOrId}` : `/watch/${slugOrId}`;
const path = `/watch/${slugOrId}`;
const { data } = await fetchWithMirror(path);
const html = typeof data === "string" ? data : String(data);
+1 -1
View File
@@ -28,7 +28,7 @@ import { fetchWithMirror } from "../helper/mirror.helper.js";
* Fetches and parses the top anime rankings from the homepage.
* Supports switching between "top" (all-time) and "newest" rankings.
*
* @param {string} sort - Ranking sort mode: "top" or "newest" (default: "top")
* @param {string} sort - Ranking sort mode: "day", "week", or "month" (default: "day")
* @returns {Promise<Array<Object>>} Array of ranked anime objects
* @returns {number} return[].rank - Ranking position (1-9)
* @returns {string} return[].slug - URL slug for the anime
-1
View File
@@ -16,7 +16,6 @@
*/
import * as cheerio from "cheerio";
import { URLS } from "../configs/dataUrl.js";
import { fetchWithMirror } from "../helper/mirror.helper.js";
// ══════════════════════════════════════════════════════════════
@@ -16,7 +16,6 @@
*/
import * as cheerio from "cheerio";
import { URLS } from "../configs/dataUrl.js";
import { fetchWithMirror } from "../helper/mirror.helper.js";
// ══════════════════════════════════════════════════════════════
@@ -17,7 +17,6 @@
import * as cheerio from "cheerio";
import { fetchWithMirror } from "../helper/mirror.helper.js";
import { parseListItems } from "../helper/parseListItem.helper.js";
// ══════════════════════════════════════════════════════════════
// UPCOMING ANIME EXTRACTION
+1 -1
View File
@@ -40,7 +40,7 @@ import { fetchWithMirror } from "../helper/mirror.helper.js";
*/
const extractWatchOrder = async (slugOrId) => {
try {
const path = /^\d+$/.test(slugOrId) ? `/watch/${slugOrId}` : `/watch/${slugOrId}`;
const path = `/watch/${slugOrId}`;
const { data } = await fetchWithMirror(path);
const html = typeof data === "string" ? data : String(data);
-1
View File
@@ -16,7 +16,6 @@
*/
import * as cheerio from "cheerio";
import { URLS, BASE_URL } from "../configs/dataUrl.js";
import { fetchWithMirror } from "../helper/mirror.helper.js";
// ══════════════════════════════════════════════════════════════
+1 -1
View File
@@ -201,7 +201,7 @@ async function fetchWithMirror(path, options = {}) {
console.log(`[MIRROR] Switched to: ${mirror}`);
}
return {
data: returnType === "text" ? response.data : response.data,
data: response.data,
mirror
};
}
+1 -1
View File
@@ -45,7 +45,7 @@
const addPaginationMeta = (data, currentPage, itemsPerPage = 30) => {
const totalPages = data.totalPages || 1;
const page = parseInt(currentPage) || 1;
const totalItems = data.data ? data.data.length * totalPages : 0;
const totalItems = data.data ? data.data.length + (totalPages - 1) * itemsPerPage : 0;
return {
...data,
+1 -1
View File
@@ -238,7 +238,7 @@ app.use((req, res, next) => {
// NOTE: Validate URL is from known streaming domains
const allowedDomains = ["vidtube.site", "vidplay.site", "megaplay.buzz", "megaplay-1.buzz", "cdn.anipixcdn.co"];
const urlObj = new URL(url);
const isAllowed = allowedDomains.some(d => urlObj.hostname.includes(d)) || urlObj.hostname.endsWith(".m3u8");
const isAllowed = allowedDomains.some(d => urlObj.hostname === d || urlObj.hostname.endsWith(`.${d}`)) || urlObj.pathname.endsWith(".m3u8");
if (!isAllowed) {
return res.status(403).json({ success: false, message: "Domain not allowed for proxy" });