mirror of
https://github.com/Shineii86/AniKotoAPI.git
synced 2026-10-22 19:05:11 +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,17 +1,55 @@
|
||||
/*
|
||||
* ======= • ======= • ======= • ======= • =======• =======
|
||||
* AniKatoAPI — azList.controller.js
|
||||
* Repository: https://github.com/Shineii86/AniKatoAPI
|
||||
*
|
||||
* @description
|
||||
* Controller for alphabetical anime listing. Returns anime
|
||||
* filtered by starting letter with pagination support.
|
||||
* Default letter is 'all' if not specified.
|
||||
*
|
||||
* @exports
|
||||
* getAzList - Express route handler for GET /api/az-list/:letter
|
||||
*
|
||||
* @author Shinei Nouzen
|
||||
* @license MIT
|
||||
* ======= • ======= • ======= • ======= • =======• =======
|
||||
*/
|
||||
|
||||
import { extractAzList } from "../extractors/azList.extractor.js";
|
||||
import { getCache, setCache } from "../helper/cache.helper.js";
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// CONTROLLER: A-Z LIST
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Alphabetical anime listing endpoint ----
|
||||
/**
|
||||
* Handles GET /api/az-list/:letter requests. Returns paginated
|
||||
* anime list filtered by the starting letter.
|
||||
*
|
||||
* @param {object} req - Express request object
|
||||
* @param {string} req.params.letter - Starting letter (default: "all")
|
||||
* @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 alphabetical anime list
|
||||
*
|
||||
* @example
|
||||
* GET /api/az-list/A?page=2
|
||||
* Response: { success: true, results: { anime, pagination, ... } }
|
||||
*
|
||||
* NOTE: Use 'all' as letter to get all anime without letter filtering
|
||||
*/
|
||||
const getAzList = async (req, res, next) => {
|
||||
try {
|
||||
const { letter = "all" } = req.params;
|
||||
const { page = 1 } = req.query;
|
||||
|
||||
const cacheKey = `azlist_${letter}_${page}`;
|
||||
const cached = getCache(cacheKey);
|
||||
if (cached) {
|
||||
return res.json({ success: true, results: cached });
|
||||
}
|
||||
|
||||
const data = await extractAzList(letter, page);
|
||||
setCache(cacheKey, data);
|
||||
res.json({ success: true, results: data });
|
||||
@@ -20,4 +58,6 @@ const getAzList = async (req, res, next) => {
|
||||
}
|
||||
};
|
||||
|
||||
export { getAzList };
|
||||
export { getAzList };
|
||||
|
||||
// ══════════════════════════════════════════════════════════════ END: azList.controller.js
|
||||
Reference in New Issue
Block a user