mirror of
https://github.com/Shineii86/MiruroAPI.git
synced 2026-10-22 10:15:10 +00:00
v1.4.0: Fix Vercel deployment, security headers, rate limiter, cache cleanup
This commit is contained in:
@@ -104,6 +104,15 @@ const setCache = (key, data, ttl = DEFAULT_TTL) => {
|
||||
cache.delete(firstKey);
|
||||
}
|
||||
|
||||
// NOTE: Periodic cleanup — prune all expired entries when cache reaches 80% capacity
|
||||
// Prevents unbounded memory growth from stale entries that were never accessed
|
||||
if (cache.size >= MAX_CACHE_SIZE * 0.8) {
|
||||
const now = Date.now();
|
||||
for (const [k, v] of cache) {
|
||||
if (now > v.expiry) cache.delete(k);
|
||||
}
|
||||
}
|
||||
|
||||
cache.set(key, { data, expiry: Date.now() + ttl });
|
||||
};
|
||||
|
||||
|
||||
@@ -355,7 +355,7 @@ const createApiRoutes = (jsonResponse, jsonError) => {
|
||||
success: true,
|
||||
results: {
|
||||
status: "healthy",
|
||||
version: "1.2.0",
|
||||
version: "1.4.0",
|
||||
uptime: `${hours}h ${minutes}m ${seconds}s`,
|
||||
uptimeSeconds: uptime,
|
||||
timestamp: new Date().toISOString(),
|
||||
@@ -404,7 +404,7 @@ const createApiRoutes = (jsonResponse, jsonError) => {
|
||||
info: {
|
||||
title: "MiruroAPI",
|
||||
description: "Free REST API for anime streaming data — AniList GraphQL + Miruro streaming providers",
|
||||
version: "1.2.0",
|
||||
version: "1.4.0",
|
||||
contact: { name: "Shineii86", url: "https://github.com/Shineii86/MiruroAPI" },
|
||||
},
|
||||
servers: [
|
||||
|
||||
Reference in New Issue
Block a user