Files
AniKotoAPI/src/controllers/upcomingAnime.controller.js
T
Shinei Nouzen fd29b02158 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
2026-07-28 19:45:25 +05:30

57 lines
2.2 KiB
JavaScript

/*
* ======= • ======= • ======= • ======= • =======• =======
* AniKotoAPI — upcomingAnime.controller.js
* Repository: https://github.com/Shineii86/AniKotoAPI
*
* @description
* Controller for upcoming anime section. Returns list of anime
* scheduled for future release from the homepage.
*
* @exports
* getUpcomingAnime - Express route handler for GET /api/upcoming
*
* @author Shinei Nouzen
* @license MIT
* ======= • ======= • ======= • ======= • =======• =======
*/
import { extractUpcomingAnime } from "../extractors/upcomingAnime.extractor.js";
import { getCache, setCache, TTL } from "../helper/cache.helper.js";
// ══════════════════════════════════════════════════════════════
// CONTROLLER: UPCOMING ANIME
// ══════════════════════════════════════════════════════════════
// ---- FEATURE: Upcoming anime endpoint ----
/**
* Handles GET /api/upcoming requests. Returns list of anime
* scheduled for future release from the homepage section.
*
* @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 upcoming anime list
*
* @example
* GET /api/upcoming
* Response: { success: true, results: [...], ... }
*/
const getUpcomingAnime = async (req, res, next) => {
try {
const cacheKey = "upcoming";
const cached = getCache(cacheKey);
if (cached) {
return res.json({ success: true, results: cached });
}
const data = await extractUpcomingAnime();
setCache(cacheKey, data, TTL.default);
res.json({ success: true, results: data });
} catch (error) {
next(error);
}
};
export { getUpcomingAnime };
// ══════════════════════════════════════════════════════════════ END: upcomingAnime.controller.js