mirror of
https://github.com/Shineii86/AniKotoAPI.git
synced 2026-10-22 10:55:10 +00:00
feat: upgrade to v2.0.0 with multi-mirror fallback, new endpoints, and LRU cache
- Add multi-mirror fallback system with 5 mirror domains - Add LRU cache with configurable TTL per endpoint - Add response compression (gzip) - Add Seasons endpoint (/api/seasons/:id) - Add Watch Order endpoint (/api/watch-order/:id) - Add Latest Updated endpoint (/api/latest-updated) - Add Download endpoint (/api/download) - Add cache stats endpoint (/api/cache/stats) - Add mirror status/reset endpoints (/api/mirrors, /api/mirrors/reset) - Add configurable rate limiting with X-RateLimit headers - Add request timeouts and entity too large handling - Update documentation with all new endpoints - Update CHANGELOG.md with v2.0.0 entry - Update package.json version to 2.0.0 - Add 6 AI agent prompts for development
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* ======= • ======= • ======= • ======= • =======• =======
|
||||
* AniKotoAPI — download.controller.js
|
||||
* Repository: https://github.com/Shineii86/AniKotoAPI
|
||||
*
|
||||
* @description
|
||||
* Controller for download links endpoint. Returns streaming server
|
||||
* URLs for downloading anime episodes.
|
||||
*
|
||||
* @exports
|
||||
* getDownloadLinks - Express route handler for GET /api/download
|
||||
*
|
||||
* @author Shinei Nouzen
|
||||
* @license MIT
|
||||
* ======= • ======= • ======= • ======= • =======• =======
|
||||
*/
|
||||
|
||||
import { extractDownloadLinks } from "../extractors/download.extractor.js";
|
||||
import { getCache, setCache, TTL } from "../helper/cache.helper.js";
|
||||
|
||||
/**
|
||||
* Handles GET /api/download requests. Returns download links
|
||||
* for the specified anime episode.
|
||||
*
|
||||
* @param {object} req - Express request object
|
||||
* @param {string} req.query.slug - Anime slug (required)
|
||||
* @param {number} req.query.ep - Episode number (required)
|
||||
* @param {object} res - Express response object
|
||||
* @param {Function} next - Express next middleware function
|
||||
* @returns {void} Sends JSON response with download links
|
||||
*
|
||||
* @example
|
||||
* GET /api/download?slug=naruto-shippuden-c8gov&ep=1
|
||||
* Response: { success: true, results: { slug, episode, downloads[] } }
|
||||
*/
|
||||
const getDownloadLinks = async (req, res, next) => {
|
||||
try {
|
||||
const { slug, ep } = req.query;
|
||||
if (!slug || !ep) {
|
||||
return res.status(400).json({
|
||||
success: false,
|
||||
message: "Both slug and ep parameters are required"
|
||||
});
|
||||
}
|
||||
|
||||
const cacheKey = `download_${slug}_${ep}`;
|
||||
const cached = getCache(cacheKey);
|
||||
if (cached) {
|
||||
return res.json({ success: true, results: cached });
|
||||
}
|
||||
|
||||
const data = await extractDownloadLinks(slug, parseInt(ep));
|
||||
setCache(cacheKey, data, TTL.stream);
|
||||
res.json({ success: true, results: data });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
};
|
||||
|
||||
export { getDownloadLinks };
|
||||
Reference in New Issue
Block a user