mirror of
https://github.com/Shineii86/AniKotoAPI.git
synced 2026-10-22 19:05:11 +00:00
feat: v2.2.0 — Modularize codebase, unify mirror fallback, harden security
Major Changes: - Add shared parseListItem.helper.js for unified list parsing (DRY) - Migrate all 22 extractors to use fetchWithMirror() for consistent mirror fallback - Remove unused cors dependency (custom CORS middleware handles it) - Fix middleware ordering: timeout now registered before routes - Fix CORS to allow POST for /api/mirrors/reset endpoint - Remove redundant cache check in homeInfo extractor New Features: - Request ID tracking (X-Request-Id header) for debugging - Graceful shutdown handling (SIGTERM/SIGINT) with 10s timeout - CSP and HSTS security headers - Rate limiter cleanup interval (every 5 min) to prevent memory leak - Request body size limits (10kb) via express.json() Security: - Content-Security-Policy header for XSS protection - Strict-Transport-Security for HTTPS enforcement - X-Permitted-Cross-Domain-Policies: none - Body size limits to prevent large payload attacks Code Quality: - All files follow strict documentation style (box headers, section separators, feature markers, JSDoc params/returns, inline notes, module footers) - Eliminated ~200 lines of duplicated code across 8+ extractors - Updated CHANGELOG.md with comprehensive change history
This commit is contained in:
@@ -15,12 +15,10 @@
|
||||
* ======= • ======= • ======= • ======= • =======• =======
|
||||
*/
|
||||
|
||||
import * as cheerio from "cheerio";
|
||||
import axios from "axios";
|
||||
import { headers } from "../configs/header.config.js";
|
||||
import { URLS } from "../configs/dataUrl.js";
|
||||
import { extractPages } from "../helper/extractPages.helper.js";
|
||||
import { countPages } from "../helper/countPages.helper.js";
|
||||
import { parseListItems } from "../helper/parseListItem.helper.js";
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// A-Z LIST EXTRACTION
|
||||
@@ -54,40 +52,10 @@ import { countPages } from "../helper/countPages.helper.js";
|
||||
*/
|
||||
const extractAzList = async (letter = "all", page = 1) => {
|
||||
try {
|
||||
// NOTE: URLS.azList generates the correct endpoint for the given letter
|
||||
const url = URLS.azList(letter);
|
||||
const $ = await extractPages(url, page);
|
||||
const totalPages = countPages($);
|
||||
|
||||
const results = [];
|
||||
|
||||
// NOTE: Multiple selectors to handle different page layouts
|
||||
$(".film_list-wrap .flw-item, .film-detail, .item").each((i, el) => {
|
||||
const slug = $(el).find("a").attr("href")?.split("/watch/").pop() || "";
|
||||
const poster = $(el).find("img").attr("src") || "";
|
||||
const title = $(el).find(".film-name a, .name.d-title").text().trim() || "";
|
||||
const japaneseTitle = $(el).find(".name.d-title").attr("data-jp") || "";
|
||||
const sub = parseInt($(el).find(".ep-status.sub span").text().trim()) || 0;
|
||||
const dub = parseInt($(el).find(".ep-status.dub span").text().trim()) || 0;
|
||||
const total = parseInt($(el).find(".ep-status.total span").text().trim()) || 0;
|
||||
const type = $(el).find(".meta .inner .right, .fdi-item:nth-child(2)").text().trim() || "";
|
||||
const rating = $(el).find(".rating, .fdi-item:nth-child(3)").text().trim() || "";
|
||||
|
||||
// NOTE: Only include items with valid slugs
|
||||
if (slug) {
|
||||
results.push({
|
||||
slug,
|
||||
poster,
|
||||
title,
|
||||
japaneseTitle,
|
||||
sub,
|
||||
dub,
|
||||
total,
|
||||
type,
|
||||
rating
|
||||
});
|
||||
}
|
||||
});
|
||||
const results = parseListItems($);
|
||||
|
||||
return { totalPages, letter, data: results };
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user