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,20 +1,57 @@
|
||||
/*
|
||||
* ======= • ======= • ======= • ======= • =======• =======
|
||||
* AniKatoAPI — schedule.controller.js
|
||||
* Repository: https://github.com/Shineii86/AniKatoAPI
|
||||
*
|
||||
* @description
|
||||
* Controller for anime airing schedule. Returns anime episodes
|
||||
* scheduled to air on a specific date. Requires date in
|
||||
* YYYY-MM-DD format as a query parameter.
|
||||
*
|
||||
* @exports
|
||||
* getSchedule - Express route handler for GET /api/schedule
|
||||
*
|
||||
* @author Shinei Nouzen
|
||||
* @license MIT
|
||||
* ======= • ======= • ======= • ======= • =======• =======
|
||||
*/
|
||||
|
||||
import { extractSchedule } from "../extractors/schedule.extractor.js";
|
||||
import { getCache, setCache } from "../helper/cache.helper.js";
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// CONTROLLER: SCHEDULE
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Anime airing schedule endpoint ----
|
||||
/**
|
||||
* Handles GET /api/schedule requests. Returns anime episodes
|
||||
* scheduled for the specified date.
|
||||
*
|
||||
* @param {object} req - Express request object
|
||||
* @param {string} req.query.date - Date in YYYY-MM-DD format
|
||||
* @param {object} res - Express response object
|
||||
* @param {Function} next - Express next middleware function
|
||||
* @returns {void} Sends JSON response with schedule data
|
||||
*
|
||||
* @example
|
||||
* GET /api/schedule?date=2024-01-15
|
||||
* Response: { success: true, results: [{ time, title, ... }] }
|
||||
*
|
||||
* @throws {400} If 'date' query parameter is missing
|
||||
* NOTE: Date must be in YYYY-MM-DD format
|
||||
*/
|
||||
const getSchedule = async (req, res, next) => {
|
||||
try {
|
||||
const { date } = req.query;
|
||||
|
||||
if (!date) {
|
||||
return res.status(400).json({ success: false, message: "Date is required (YYYY-MM-DD)" });
|
||||
}
|
||||
|
||||
const cacheKey = `schedule_${date}`;
|
||||
const cached = getCache(cacheKey);
|
||||
if (cached) {
|
||||
return res.json({ success: true, results: cached });
|
||||
}
|
||||
|
||||
const data = await extractSchedule(date);
|
||||
setCache(cacheKey, data);
|
||||
res.json({ success: true, results: data });
|
||||
@@ -23,4 +60,6 @@ const getSchedule = async (req, res, next) => {
|
||||
}
|
||||
};
|
||||
|
||||
export { getSchedule };
|
||||
export { getSchedule };
|
||||
|
||||
// ══════════════════════════════════════════════════════════════ END: schedule.controller.js
|
||||
Reference in New Issue
Block a user