mirror of
https://github.com/Shineii86/AniKotoAPI.git
synced 2026-10-22 19:05:11 +00:00
feat: Add new endpoints and enhance filter — v2.2.0
New Endpoints (4 new routes): - GET /api/upcoming — upcoming anime releases from homepage - GET /api/top-rankings?sort=top|newest — ranked anime with sort modes - GET /api/recently-updated?tab=all|dub|sub — filtered recent updates - GET /api/completed — finished anime series from homepage Enhanced Filter (/api/filter): - Added source parameter (18 source material types) - Added epMin/epMax for episode range filtering - Added excludeWatchlist parameter for logged-in users - Added season parameter (spring/summer/fall/winter) New Config IDs: - SOURCE_IDS: 18 source material type mappings - SEASON_IDS: 4 broadcast season mappings - EXTENDED_TYPE_IDS: Added tv-short and tv-special types Total endpoints: 34 (was 30) OpenAPI spec updated with new endpoints CHANGELOG.md updated with comprehensive change history
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* ======= • ======= • ======= • ======= • =======• =======
|
||||
* AniKotoAPI — recentlyUpdatedTabs.controller.js
|
||||
* Repository: https://github.com/Shineii86/AniKotoAPI
|
||||
*
|
||||
* @description
|
||||
* Controller for recently updated anime with tab filtering.
|
||||
* Returns recently updated anime filtered by all, dub, or sub.
|
||||
*
|
||||
* @exports
|
||||
* getRecentlyUpdatedTabs - Express route handler for GET /api/recently-updated
|
||||
*
|
||||
* @author Shinei Nouzen
|
||||
* @license MIT
|
||||
* ======= • ======= • ======= • ======= • =======• =======
|
||||
*/
|
||||
|
||||
import { extractRecentlyUpdatedTabs } from "../extractors/recentlyUpdatedTabs.extractor.js";
|
||||
import { getCache, setCache, TTL } from "../helper/cache.helper.js";
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// CONTROLLER: RECENTLY UPDATED TABS
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Recently updated with tab filtering endpoint ----
|
||||
/**
|
||||
* Handles GET /api/recently-updated requests. Returns recently updated
|
||||
* anime filtered by tab: all, dub, or sub.
|
||||
*
|
||||
* @param {object} req - Express request object
|
||||
* @param {string} [req.query.tab="all"] - Tab filter: "all", "dub", or "sub"
|
||||
* @param {object} res - Express response object
|
||||
* @param {Function} next - Express next middleware function
|
||||
* @returns {void} Sends JSON response with recently updated anime list
|
||||
*
|
||||
* @example
|
||||
* GET /api/recently-updated?tab=dub
|
||||
* Response: { success: true, results: [...], tab: "dub" }
|
||||
*/
|
||||
const getRecentlyUpdatedTabs = async (req, res, next) => {
|
||||
try {
|
||||
const { tab = "all" } = req.query;
|
||||
const cacheKey = `recently_updated_${tab}`;
|
||||
const cached = getCache(cacheKey);
|
||||
if (cached) {
|
||||
return res.json({ success: true, results: cached, tab });
|
||||
}
|
||||
const data = await extractRecentlyUpdatedTabs(tab);
|
||||
setCache(cacheKey, data, TTL.default);
|
||||
res.json({ success: true, results: data, tab });
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
};
|
||||
|
||||
export { getRecentlyUpdatedTabs };
|
||||
|
||||
// ══════════════════════════════════════════════════════════════ END: recentlyUpdatedTabs.controller.js
|
||||
Reference in New Issue
Block a user