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:
@@ -17,8 +17,8 @@
|
||||
* ======= • ======= • ======= • ======= • =======• =======
|
||||
*/
|
||||
|
||||
import { extractNewRelease, extractNewlyAdded } from "../extractors/newRelease.extractor.js";
|
||||
import { getCache, setCache } from "../helper/cache.helper.js";
|
||||
import { extractNewRelease, extractNewlyAdded, extractLatestUpdated } from "../extractors/newRelease.extractor.js";
|
||||
import { getCache, setCache, TTL } from "../helper/cache.helper.js";
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// CONTROLLER: NEW RELEASE
|
||||
@@ -48,7 +48,7 @@ const getNewRelease = async (req, res, next) => {
|
||||
return res.json({ success: true, results: cached });
|
||||
}
|
||||
const data = await extractNewRelease(page);
|
||||
setCache(cacheKey, data);
|
||||
setCache(cacheKey, data, TTL.default);
|
||||
res.json({ success: true, results: data });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
@@ -83,13 +83,47 @@ const getNewlyAdded = async (req, res, next) => {
|
||||
return res.json({ success: true, results: cached });
|
||||
}
|
||||
const data = await extractNewlyAdded(page);
|
||||
setCache(cacheKey, data);
|
||||
setCache(cacheKey, data, TTL.default);
|
||||
res.json({ success: true, results: data });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
};
|
||||
|
||||
export { getNewRelease, getNewlyAdded };
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// CONTROLLER: LATEST UPDATED
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
/**
|
||||
* Handles GET /api/latest-updated requests. Returns paginated list
|
||||
* of recently updated anime sorted by last update time.
|
||||
*
|
||||
* @param {object} req - Express request object
|
||||
* @param {number} req.query.page - Page number (default: 1)
|
||||
* @param {object} res - Express response object
|
||||
* @param {Function} next - Express next middleware function
|
||||
* @returns {void} Sends JSON response with latest updated anime
|
||||
*
|
||||
* @example
|
||||
* GET /api/latest-updated?page=2
|
||||
* Response: { success: true, results: { totalPages, data[] } }
|
||||
*/
|
||||
const getLatestUpdated = async (req, res, next) => {
|
||||
try {
|
||||
const { page = 1 } = req.query;
|
||||
const cacheKey = `latestupdated_${page}`;
|
||||
const cached = getCache(cacheKey);
|
||||
if (cached) {
|
||||
return res.json({ success: true, results: cached });
|
||||
}
|
||||
const data = await extractLatestUpdated(page);
|
||||
setCache(cacheKey, data, TTL.default);
|
||||
res.json({ success: true, results: data });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
};
|
||||
|
||||
export { getNewRelease, getNewlyAdded, getLatestUpdated };
|
||||
|
||||
// ══════════════════════════════════════════════════════════════ END: newRelease.controller.js
|
||||
Reference in New Issue
Block a user