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:
+115
-1
@@ -1,3 +1,21 @@
|
||||
/*
|
||||
* ======= • ======= • ======= • ======= • =======• =======
|
||||
* AniKatoAPI — apiRoutes.js
|
||||
* Repository: https://github.com/Shineii86/AniKatoAPI
|
||||
*
|
||||
* @description
|
||||
* Central API router that maps all Express GET endpoints to their
|
||||
* corresponding controller handlers. Each route wraps its controller
|
||||
* in try/catch for consistent error handling.
|
||||
*
|
||||
* @exports
|
||||
* createApiRoutes - Function that registers all API routes on the Express app
|
||||
*
|
||||
* @author Shinei Nouzen
|
||||
* @license MIT
|
||||
* ======= • ======= • ======= • ======= • =======• =======
|
||||
*/
|
||||
|
||||
import { getHomeInfo } from "../controllers/homeInfo.controller.js";
|
||||
import { getAnimeInfo } from "../controllers/animeInfo.controller.js";
|
||||
import { getSearchResults, getSearchSuggestions } from "../controllers/search.controller.js";
|
||||
@@ -21,7 +39,29 @@ import { getSeasons } from "../controllers/seasons.controller.js";
|
||||
import { getWatchOrder } from "../controllers/watchOrder.controller.js";
|
||||
import { categoryRoutes } from "./category.route.js";
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// ROUTE REGISTRATION
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Main API route registration function ----
|
||||
/**
|
||||
* Registers all API routes on the Express app instance.
|
||||
* Each route delegates to a controller and uses the provided
|
||||
* jsonResponse/jsonError helpers for consistent output.
|
||||
*
|
||||
* @param {object} app - Express application instance
|
||||
* @param {Function} jsonResponse - Helper to wrap data in success JSON
|
||||
* @param {Function} jsonError - Helper to return error JSON
|
||||
*
|
||||
* @example
|
||||
* createApiRoutes(app, jsonResponse, jsonError);
|
||||
*/
|
||||
const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// HOME
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Homepage data endpoint ----
|
||||
app.get("/api/", async (req, res, next) => {
|
||||
try {
|
||||
await getHomeInfo(req, res, next);
|
||||
@@ -30,6 +70,11 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// ANIME INFO
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Anime detail information by slug ----
|
||||
app.get("/api/info", async (req, res, next) => {
|
||||
try {
|
||||
await getAnimeInfo(req, res, next);
|
||||
@@ -38,6 +83,11 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// WATCH PAGE
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Watch page data for specific episode ----
|
||||
app.get("/api/watch", async (req, res, next) => {
|
||||
try {
|
||||
await getWatchPage(req, res, next);
|
||||
@@ -46,6 +96,11 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// SEARCH
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Full search results with pagination ----
|
||||
app.get("/api/search", async (req, res, next) => {
|
||||
try {
|
||||
await getSearchResults(req, res, next);
|
||||
@@ -54,6 +109,7 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ---- FEATURE: Search autocomplete suggestions ----
|
||||
app.get("/api/search/suggest", async (req, res, next) => {
|
||||
try {
|
||||
await getSearchSuggestions(req, res, next);
|
||||
@@ -62,6 +118,11 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// EPISODES
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Episode list for anime by ID ----
|
||||
app.get("/api/episodes/:id", async (req, res, next) => {
|
||||
try {
|
||||
await getEpisodeList(req, res, next);
|
||||
@@ -70,6 +131,7 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ---- FEATURE: AJAX-loaded episode list (additional data) ----
|
||||
app.get("/api/episodes-ajax/:id", async (req, res, next) => {
|
||||
try {
|
||||
await getEpisodeListAjax(req, res, next);
|
||||
@@ -78,6 +140,11 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// STREAMING
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Stream URL and metadata for episode ----
|
||||
app.get("/api/stream", async (req, res, next) => {
|
||||
try {
|
||||
await getStreamInfo(req, res, next);
|
||||
@@ -86,6 +153,7 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ---- FEATURE: Available streaming servers for episode ----
|
||||
app.get("/api/servers", async (req, res, next) => {
|
||||
try {
|
||||
await getServerList(req, res, next);
|
||||
@@ -94,6 +162,7 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ---- FEATURE: Mapped servers across multiple episodes ----
|
||||
app.get("/api/mapper-servers", async (req, res, next) => {
|
||||
try {
|
||||
await getMapperServers(req, res, next);
|
||||
@@ -102,6 +171,11 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// SCHEDULE
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Anime airing schedule by date ----
|
||||
app.get("/api/schedule", async (req, res, next) => {
|
||||
try {
|
||||
await getSchedule(req, res, next);
|
||||
@@ -110,6 +184,11 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// DISCOVERY / HOMEPAGE SECTIONS
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Spotlight/featured anime carousel ----
|
||||
app.get("/api/spotlight", async (req, res, next) => {
|
||||
try {
|
||||
await getSpotlight(req, res, next);
|
||||
@@ -118,6 +197,7 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ---- FEATURE: Currently trending anime ----
|
||||
app.get("/api/trending", async (req, res, next) => {
|
||||
try {
|
||||
await getTrending(req, res, next);
|
||||
@@ -126,6 +206,7 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ---- FEATURE: Top 10 ranked anime ----
|
||||
app.get("/api/top-ten", async (req, res, next) => {
|
||||
try {
|
||||
await getTopTen(req, res, next);
|
||||
@@ -134,6 +215,7 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ---- FEATURE: Auto-complete suggestions by keyword ----
|
||||
app.get("/api/suggestions", async (req, res, next) => {
|
||||
try {
|
||||
await getSuggestions(req, res, next);
|
||||
@@ -142,6 +224,7 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ---- FEATURE: Random anime recommendation ----
|
||||
app.get("/api/random", async (req, res, next) => {
|
||||
try {
|
||||
await getRandom(req, res, next);
|
||||
@@ -150,6 +233,7 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ---- FEATURE: Most popular anime list ----
|
||||
app.get("/api/most-popular", async (req, res, next) => {
|
||||
try {
|
||||
await getPopular(req, res, next);
|
||||
@@ -158,6 +242,7 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ---- FEATURE: Advanced filter/search by parameters ----
|
||||
app.get("/api/filter", async (req, res, next) => {
|
||||
try {
|
||||
await getFilter(req, res, next);
|
||||
@@ -166,6 +251,11 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// RELEASE LISTS
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Recently released episodes ----
|
||||
app.get("/api/new-release", async (req, res, next) => {
|
||||
try {
|
||||
await getNewRelease(req, res, next);
|
||||
@@ -174,6 +264,7 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ---- FEATURE: Newly added anime series ----
|
||||
app.get("/api/newly-added", async (req, res, next) => {
|
||||
try {
|
||||
await getNewlyAdded(req, res, next);
|
||||
@@ -182,6 +273,11 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// SIDEBAR
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Trending sidebar widget data ----
|
||||
app.get("/api/trending-sidebar", async (req, res, next) => {
|
||||
try {
|
||||
await getTrendingSidebar(req, res, next);
|
||||
@@ -190,6 +286,11 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// SEASONS & WATCH ORDER
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Season information for anime ----
|
||||
app.get("/api/seasons/:id", async (req, res, next) => {
|
||||
try {
|
||||
await getSeasons(req, res, next);
|
||||
@@ -198,6 +299,7 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ---- FEATURE: Recommended watch order for anime ----
|
||||
app.get("/api/watch-order/:id", async (req, res, next) => {
|
||||
try {
|
||||
await getWatchOrder(req, res, next);
|
||||
@@ -206,6 +308,11 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// A-Z LIST
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// ---- FEATURE: Alphabetical anime listing ----
|
||||
app.get("/api/az-list/:letter", async (req, res, next) => {
|
||||
try {
|
||||
await getAzList(req, res, next);
|
||||
@@ -214,7 +321,14 @@ const createApiRoutes = (app, jsonResponse, jsonError) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
// CATEGORY ROUTES
|
||||
// ══════════════════════════════════════════════════════════════
|
||||
|
||||
// NOTE: Category routes (genre, type, status) are registered separately
|
||||
categoryRoutes(app, jsonResponse, jsonError);
|
||||
};
|
||||
|
||||
export { createApiRoutes };
|
||||
export { createApiRoutes };
|
||||
|
||||
// ══════════════════════════════════════════════════════════════ END: apiRoutes.js
|
||||
Reference in New Issue
Block a user