Optimize frontend rendering, CSS, and backend history caching
This commit is contained in:
+7
-2
@@ -82,17 +82,22 @@ console.log(`[startup] Listening on: http://0.0.0.0:${PORT}`);
|
||||
// History helpers
|
||||
// ──────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
let historyCache = null;
|
||||
|
||||
async function readHistory() {
|
||||
if (historyCache !== null) return historyCache;
|
||||
try {
|
||||
const raw = await readFile(HISTORY_FILE, 'utf-8');
|
||||
const parsed = JSON.parse(raw);
|
||||
return Array.isArray(parsed) ? parsed : [];
|
||||
historyCache = Array.isArray(parsed) ? parsed : [];
|
||||
} catch {
|
||||
return [];
|
||||
historyCache = [];
|
||||
}
|
||||
return historyCache;
|
||||
}
|
||||
|
||||
async function writeHistory(entries) {
|
||||
historyCache = entries;
|
||||
await writeFile(HISTORY_FILE, JSON.stringify(entries, null, 2), 'utf-8');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user