POST /claude-usage now merges every day of the sanitized snapshot except the last one (today, still open) into <dir of CLAUDE_USAGE_PATH>/history/ YYYY-MM.json, after the snapshot itself is written. The latest snapshot wins, so a day leaving the 30-day window keeps the value the agent froze at D+2. Each month file is written atomically (same-dir temp, mode 600, rename). A month file that cannot be read back is never overwritten, and an archive failure is logged (months and error codes only) without changing the 204. GET /claude-usage/history?from=YYYY-MM&to=YYYY-MM (read token) serves the archived days, defaulting to the 12 months up to the last archived month, 400 on a bad format, from > to or a span over 36 months. Month files are re-read through the snapshot's per-day whitelist, now exported from claude-usage.js as sanitizeDay(). The new module also carries the one-shot import command used by the backfill (`node claude-usage-history.js --import <file|->`), where an already archived date always wins. Refs #55 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 lines
161 B
Docker
6 lines
161 B
Docker
FROM node:22-alpine
|
|
WORKDIR /app
|
|
COPY package.json index.js metrics.js claude-usage.js claude-usage-history.js ./
|
|
EXPOSE 3001
|
|
USER node
|
|
CMD ["node", "index.js"]
|