v1.9.1: Fix 4 critical bugs from sed operations

- apiRoutes.js: Moved imports outside comment block (caused 500 on all endpoints)
- test.js: Deleted orphaned duplicate code after function close
- random.controller.js: Removed stray closing brace breaking try/catch
- cache.helper.js: Added missing MAX_CACHE_SIZE constant

These bugs were introduced by sed insert commands placing code in wrong positions.
The API was returning 500 FUNCTION_INVOCATION_FAILED on all endpoints.
This commit is contained in:
Sʜɪɴᴇɪ Nᴏᴜᴢᴇɴ
2026-06-09 06:11:51 +05:30
parent 100b9f9414
commit cc145c9acc
4 changed files with 6 additions and 18 deletions
-1
View File
@@ -38,7 +38,6 @@ import { extractRandom } from "../extractors/random.extractor.js";
*/ */
const getRandom = async (req, res, next) => { const getRandom = async (req, res, next) => {
try { try {
}
const data = await extractRandom(); const data = await extractRandom();
res.json({ success: true, results: data }); res.json({ success: true, results: data });
} catch (error) { } catch (error) {
+2
View File
@@ -40,6 +40,8 @@ const cache = new Map();
* @default 300000 * @default 300000
*/ */
const CACHE_TTL = 5 * 60 * 1000; const CACHE_TTL = 5 * 60 * 1000;
// ---- FEATURE: Maximum cache size ----
const MAX_CACHE_SIZE = 100;
// ══════════════════════════════════════════════════════════════ // ══════════════════════════════════════════════════════════════
// CACHE OPERATIONS // CACHE OPERATIONS
+4 -3
View File
@@ -1,8 +1,5 @@
/* /*
* ======= • ======= • ======= • ======= • =======• ======= * ======= • ======= • ======= • ======= • =======• =======
import { createRequire } from "module";
const require = createRequire(import.meta.url);
const { version } = require("../package.json");
* AniKotoAPI — apiRoutes.js * AniKotoAPI — apiRoutes.js
* Repository: https://github.com/Shineii86/AniKotoAPI * Repository: https://github.com/Shineii86/AniKotoAPI
* *
@@ -18,6 +15,10 @@ const { version } = require("../package.json");
* @license MIT * @license MIT
* ======= • ======= • ======= • ======= • =======• ======= * ======= • ======= • ======= • ======= • =======• =======
*/ */
import { createRequire } from "module";
const require = createRequire(import.meta.url);
const { version } = require("../package.json");
import { getHomeInfo } from "../controllers/homeInfo.controller.js"; import { getHomeInfo } from "../controllers/homeInfo.controller.js";
import { getAnimeInfo } from "../controllers/animeInfo.controller.js"; import { getAnimeInfo } from "../controllers/animeInfo.controller.js";
-14
View File
@@ -71,20 +71,6 @@ async function runTest(test) {
failed++; failed++;
} }
} }
const data = await res.json();
if (data.success === true && data.results) {
console.log(`✅ ${test.name}`);
passed++;
} else {
console.log(`❌ ${test.name} - Invalid response format`);
failed++;
}
} catch (error) {
console.log(`❌ ${test.name} - ${error.message}`);
failed++;
}
}
async function runAll() { async function runAll() {
console.log(`\n🧪 Running ${tests.length} tests...\n`); console.log(`\n🧪 Running ${tests.length} tests...\n`);