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,6 +1,44 @@
|
||||
/*
|
||||
* ======= • ======= • ======= • ======= • =======• =======
|
||||
* AniKatoAPI — newRelease.controller.js
|
||||
* Repository: https://github.com/Shineii86/AniKatoAPI
|
||||
*
|
||||
* @description
|
||||
* Controller for new release and newly added anime. Provides
|
||||
* two endpoints: one for recently released episodes and one
|
||||
* for newly added anime series. Both support pagination.
|
||||
*
|
||||
* @exports
|
||||
* getNewRelease - Express route handler for GET /api/new-release
|
||||
* getNewlyAdded - Express route handler for GET /api/newly-added
|
||||
*
|
||||
* @author Shinei Nouzen
|
||||
* @license MIT
|
||||
* ======= • ======= • ======= • ======= • =======• =======
|
||||
*/
|
||||
|
||||
import { extractNewRelease, extractNewlyAdded } from "../extractors/newRelease.extractor.js";
|
||||
import { getCache, setCache } from "../helper/cache.helper.js";
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// CONTROLLER: NEW RELEASE
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Recently released episodes endpoint ----
|
||||
/**
|
||||
* Handles GET /api/new-release requests. Returns paginated list
|
||||
* of recently released anime episodes.
|
||||
*
|
||||
* @param {object} req - Express request object
|
||||
* @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 new release episodes
|
||||
*
|
||||
* @example
|
||||
* GET /api/new-release?page=2
|
||||
* Response: { success: true, results: { episodes, pagination, ... } }
|
||||
*/
|
||||
const getNewRelease = async (req, res, next) => {
|
||||
try {
|
||||
const { page = 1 } = req.query;
|
||||
@@ -9,7 +47,6 @@ const getNewRelease = async (req, res, next) => {
|
||||
if (cached) {
|
||||
return res.json({ success: true, results: cached });
|
||||
}
|
||||
|
||||
const data = await extractNewRelease(page);
|
||||
setCache(cacheKey, data);
|
||||
res.json({ success: true, results: data });
|
||||
@@ -18,6 +55,25 @@ const getNewRelease = async (req, res, next) => {
|
||||
}
|
||||
};
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// CONTROLLER: NEWLY ADDED
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Newly added anime series endpoint ----
|
||||
/**
|
||||
* Handles GET /api/newly-added requests. Returns paginated list
|
||||
* of newly added anime series to the platform.
|
||||
*
|
||||
* @param {object} req - Express request object
|
||||
* @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 newly added anime
|
||||
*
|
||||
* @example
|
||||
* GET /api/newly-added?page=3
|
||||
* Response: { success: true, results: { anime, pagination, ... } }
|
||||
*/
|
||||
const getNewlyAdded = async (req, res, next) => {
|
||||
try {
|
||||
const { page = 1 } = req.query;
|
||||
@@ -26,7 +82,6 @@ const getNewlyAdded = async (req, res, next) => {
|
||||
if (cached) {
|
||||
return res.json({ success: true, results: cached });
|
||||
}
|
||||
|
||||
const data = await extractNewlyAdded(page);
|
||||
setCache(cacheKey, data);
|
||||
res.json({ success: true, results: data });
|
||||
@@ -35,4 +90,6 @@ const getNewlyAdded = async (req, res, next) => {
|
||||
}
|
||||
};
|
||||
|
||||
export { getNewRelease, getNewlyAdded };
|
||||
export { getNewRelease, getNewlyAdded };
|
||||
|
||||
// ══════════════════════════════════════════════════════════════ END: newRelease.controller.js
|
||||
Reference in New Issue
Block a user