mirror of
https://github.com/Shineii86/AniKotoAPI.git
synced 2026-10-22 10:55:10 +00:00
- Fix /api/watch 500: correct URL path format (slug/ep-N -> slug/ep-N) - Fix /api/info: accept both ?id= and ?slug= query params - Fix /api/status/airing 500: map short status names (ongoing/airing/completed) to correct slugs - Fix /api/top-rankings: correct selectors (#top-anime .scaff.side.items a.item) + extract rank from rankN class - Fix /api/completed: correct selectors (section.top-table[data-name='completed'] a.item) - Fix /api/recently-updated: correct selectors (#recent-update .ani.items .item) + client-side tab filtering - Fix parseListItem: detect self-as-anchor (<a> elements) + fallback slug extraction - Fix category extractor: add status name mapping (ongoing->currently-airing, etc.) - Add /api/cache/stats endpoint for LRU cache diagnostics - 33 endpoints verified: 0 errors, 0 timeouts
64 lines
2.5 KiB
JavaScript
64 lines
2.5 KiB
JavaScript
/*
|
|
* ======= • ======= • ======= • ======= • =======• =======
|
|
* AniKotoAPI — animeInfo.controller.js
|
|
* Repository: https://github.com/Shineii86/AniKotoAPI
|
|
*
|
|
* @description
|
|
* Controller for anime detail information. Extracts full anime
|
|
* metadata including title, synopsis, episodes, genres, etc.
|
|
* Requires an anime slug as query parameter.
|
|
*
|
|
* @exports
|
|
* getAnimeInfo - Express route handler for GET /api/info
|
|
*
|
|
* @author Shinei Nouzen
|
|
* @license MIT
|
|
* ======= • ======= • ======= • ======= • =======• =======
|
|
*/
|
|
|
|
import { extractAnimeInfo } from "../extractors/animeInfo.extractor.js";
|
|
import { getCache, setCache, TTL } from "../helper/cache.helper.js";
|
|
|
|
// ══════════════════════════════════════════════════════════════
|
|
// CONTROLLER: ANIME INFO
|
|
// ══════════════════════════════════════════════════════════════
|
|
|
|
// ---- FEATURE: Anime detail information endpoint ----
|
|
/**
|
|
* Handles GET /api/info requests by extracting detailed anime
|
|
* information from the source site. Requires 'id' query param.
|
|
*
|
|
* @param {object} req - Express request object
|
|
* @param {object} res - Express response object
|
|
* @param {Function} next - Express next middleware function
|
|
* @returns {void} Sends JSON response with anime details
|
|
*
|
|
* @example
|
|
* GET /api/info?id=one-piece
|
|
* Response: { success: true, results: { title, synopsis, ... } }
|
|
*
|
|
* @throws {400} If 'id' query parameter is missing
|
|
*/
|
|
const getAnimeInfo = async (req, res, next) => {
|
|
try {
|
|
const { id, slug } = req.query;
|
|
const animeSlug = id || slug;
|
|
if (!animeSlug) {
|
|
return res.status(400).json({ success: false, message: "Anime slug is required (?id= or ?slug=)" });
|
|
}
|
|
const cacheKey = `anime_${animeSlug}`;
|
|
const cached = getCache(cacheKey);
|
|
if (cached) {
|
|
return res.json({ success: true, results: cached });
|
|
}
|
|
const data = await extractAnimeInfo(animeSlug);
|
|
setCache(cacheKey, data, TTL.info);
|
|
res.json({ success: true, results: data });
|
|
} catch (error) {
|
|
next(error);
|
|
}
|
|
};
|
|
|
|
export { getAnimeInfo };
|
|
|
|
// ══════════════════════════════════════════════════════════════ END: animeInfo.controller.js
|