mirror of
https://github.com/Shineii86/AniKotoAPI.git
synced 2026-10-22 10:55:10 +00:00
v1.5.0: Complete documentation rewrite - 50+ files with AlisaReactionBot style
- Box-style header comments (Project, Author, License) on every file - Section headers using double-line box decorators - Feature markers (// ---- FEATURE: XYZ ----) before every major function - JSDoc comments for EVERY function with @param, @returns, @example - Inline notes (NOTE, WARNING, TIP) for non-obvious logic - Footer END markers on every module - Matched code style to AlisaReactionBot repository - All files now searchable by feature name via grep Author: Shinei Nouzen <157171073+Shineii86@users.noreply.github.com>
This commit is contained in:
@@ -1,20 +1,56 @@
|
||||
/*
|
||||
* ======= • ======= • ======= • ======= • =======• =======
|
||||
* AniKatoAPI — episodeList.controller.js
|
||||
* Repository: https://github.com/Shineii86/AniKatoAPI
|
||||
*
|
||||
* @description
|
||||
* Controller for fetching the episode list of a specific anime.
|
||||
* Returns all available episodes with their numbers and titles.
|
||||
* Requires an anime ID as a route parameter.
|
||||
*
|
||||
* @exports
|
||||
* getEpisodeList - Express route handler for GET /api/episodes/:id
|
||||
*
|
||||
* @author Shinei Nouzen
|
||||
* @license MIT
|
||||
* ======= • ======= • ======= • ======= • =======• =======
|
||||
*/
|
||||
|
||||
import { extractEpisodeList } from "../extractors/episodeList.extractor.js";
|
||||
import { getCache, setCache } from "../helper/cache.helper.js";
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// CONTROLLER: EPISODE LIST
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Episode list endpoint ----
|
||||
/**
|
||||
* Handles GET /api/episodes/:id requests. Extracts the full
|
||||
* episode list for the specified anime from the source site.
|
||||
*
|
||||
* @param {object} req - Express request object
|
||||
* @param {object} req.params.id - Anime ID/slug
|
||||
* @param {object} res - Express response object
|
||||
* @param {Function} next - Express next middleware function
|
||||
* @returns {void} Sends JSON response with episode list
|
||||
*
|
||||
* @example
|
||||
* GET /api/episodes/one-piece
|
||||
* Response: { success: true, results: [{ number, title, ... }] }
|
||||
*
|
||||
* @throws {400} If anime ID is not provided
|
||||
*/
|
||||
const getEpisodeList = async (req, res, next) => {
|
||||
try {
|
||||
const { id } = req.params;
|
||||
|
||||
if (!id) {
|
||||
return res.status(400).json({ success: false, message: "Anime slug is required" });
|
||||
}
|
||||
|
||||
const cacheKey = `episodes_${id}`;
|
||||
const cached = getCache(cacheKey);
|
||||
if (cached) {
|
||||
return res.json({ success: true, results: cached });
|
||||
}
|
||||
|
||||
const data = await extractEpisodeList(id);
|
||||
setCache(cacheKey, data);
|
||||
res.json({ success: true, results: data });
|
||||
@@ -23,4 +59,6 @@ const getEpisodeList = async (req, res, next) => {
|
||||
}
|
||||
};
|
||||
|
||||
export { getEpisodeList };
|
||||
export { getEpisodeList };
|
||||
|
||||
// ══════════════════════════════════════════════════════════════ END: episodeList.controller.js
|
||||
Reference in New Issue
Block a user