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,6 +1,49 @@
|
||||
/*
|
||||
* ======= • ======= • ======= • ======= • =======• =======
|
||||
* AniKatoAPI — filter.controller.js
|
||||
* Repository: https://github.com/Shineii86/AniKatoAPI
|
||||
*
|
||||
* @description
|
||||
* Controller for advanced anime filtering. Accepts multiple query
|
||||
* parameters to filter anime by genre, year, season, type, status,
|
||||
* and more. All parameters are forwarded to the extractor.
|
||||
*
|
||||
* @exports
|
||||
* getFilter - Express route handler for GET /api/filter
|
||||
*
|
||||
* @author Shinei Nouzen
|
||||
* @license MIT
|
||||
* ======= • ======= • ======= • ======= • =======• =======
|
||||
*/
|
||||
|
||||
import { extractFilter } from "../extractors/filter.extractor.js";
|
||||
import { getCache, setCache } from "../helper/cache.helper.js";
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// CONTROLLER: FILTER
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Advanced filter endpoint ----
|
||||
/**
|
||||
* Handles GET /api/filter requests. Returns filtered anime list
|
||||
* based on provided query parameters.
|
||||
*
|
||||
* @param {object} req - Express request object
|
||||
* @param {string} req.query.genre - Genre filter (optional)
|
||||
* @param {string} req.query.year - Year filter (optional)
|
||||
* @param {string} req.query.season - Season filter (optional)
|
||||
* @param {string} req.query.type - Type filter (optional)
|
||||
* @param {string} req.query.status - Status filter (optional)
|
||||
* @param {number} req.query.page - Page number (optional, default: 1)
|
||||
* @param {object} res - Express response object
|
||||
* @param {Function} next - Express next middleware function
|
||||
* @returns {void} Sends JSON response with filtered anime list
|
||||
*
|
||||
* @example
|
||||
* GET /api/filter?genre=action&year=2024&type=tv
|
||||
* Response: { success: true, results: { anime, pagination, ... } }
|
||||
* NOTE: The cache key uses JSON.stringify of all params for unique caching
|
||||
*/
|
||||
const getFilter = async (req, res, next) => {
|
||||
try {
|
||||
const params = req.query;
|
||||
@@ -9,7 +52,6 @@ const getFilter = async (req, res, next) => {
|
||||
if (cached) {
|
||||
return res.json({ success: true, results: cached });
|
||||
}
|
||||
|
||||
const data = await extractFilter(params);
|
||||
setCache(cacheKey, data);
|
||||
res.json({ success: true, results: data });
|
||||
@@ -18,4 +60,6 @@ const getFilter = async (req, res, next) => {
|
||||
}
|
||||
};
|
||||
|
||||
export { getFilter };
|
||||
export { getFilter };
|
||||
|
||||
// ══════════════════════════════════════════════════════════════ END: filter.controller.js
|
||||
Reference in New Issue
Block a user