Fix boot sequence alignment, rate limiter memory leak, and docs gaps

- base.js: Fix boot sequence title centering — old formula was off by 1
  char for odd-length app names (PULSE, GANDALF). Remove unused `bar`
  variable. New logic computes left/right padding independently to
  handle both even and odd title lengths correctly.
- node/middleware.js: Prune expired rate-limit entries from Map when
  size exceeds 5000 to prevent unbounded memory growth. Also use
  req.socket?.remoteAddress as fallback for req.ip.
- README.md: Document lt.beep() in the JS API section. Clarify Quick
  Start to distinguish core files from platform-specific helpers.
  Note that tableNav.init() and sortTable.init() require explicit calls.
- aesthetic_diff.md: Correct §8 toast icon format — base.js uses
  bracketed symbols [✓][✗][!][i], not >> prefix as previously stated.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-14 21:27:31 -04:00
parent 66538f9ad8
commit 997450aaf1
4 changed files with 33 additions and 12 deletions

View File

@@ -189,13 +189,19 @@ function createRateLimit(opts) {
const hits = new Map();
return function rateLimit(req, res, next) {
const key = req.ip || 'unknown';
const key = req.ip || req.socket?.remoteAddress || 'unknown';
const now = Date.now();
const entry = hits.get(key) || { count: 0, reset: now + windowMs };
if (now > entry.reset) {
entry.count = 0;
entry.reset = now + windowMs;
/* Prune expired entries periodically to prevent memory growth */
if (hits.size > 5000) {
for (const [k, v] of hits) {
if (now > v.reset) hits.delete(k);
}
}
}
entry.count++;
hits.set(key, entry);