Skip to content

[codex] Add ETags for events and stats#210

Open
pq198363-ops wants to merge 1 commit into
Agentpay-Org:mainfrom
pq198363-ops:bounty-145-events-stats-etag
Open

[codex] Add ETags for events and stats#210
pq198363-ops wants to merge 1 commit into
Agentpay-Org:mainfrom
pq198363-ops:bounty-145-events-stats-etag

Conversation

@pq198363-ops

Copy link
Copy Markdown

Summary

Closes #145.

  • Add a shared etagFor helper for weak cache validators.
  • Reuse the helper for the existing services list ETag path.
  • Add explicit weak ETags and If-None-Match 304 handling for GET /api/v1/events and GET /api/v1/stats.
  • Scope events validators to the effective since, type, and limit query values so different filtered poll requests cannot collide when their bodies are currently identical.
  • Document conditional polling support in the README.

RED/GREEN

RED before implementation:

npm run build
NODE_ENV=test node --test dist/etag-events-stats.test.js

fail 1
uses query-specific events ETags even when filtered bodies match
actual and expected both: W/"c-F6g7sByJuuOcYYkgTnzj94yg+ZE"

GREEN after implementation:

npm run build
NODE_ENV=test node --test dist/etag-events-stats.test.js

tests 4
pass 4
fail 0

Verification

npx prettier --check README.md src/httpCache.ts src/routes/events.ts src/routes/metrics.ts src/routes/services.ts src/etag-events-stats.test.ts
All matched files use Prettier code style!

npm run lint
eslint .

npm run build
NODE_ENV=test node --test dist/etag-events-stats.test.js
tests 4
pass 4
fail 0

NODE_ENV=test node --test dist/*.test.js dist/**/*.test.js
tests 93
pass 93
fail 0

git diff --check

Note: on Windows PowerShell I used the direct $env:NODE_ENV='test'; node --test ... equivalent after npm run build because the package npm test script uses POSIX-style NODE_ENV=test syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a weak ETag and If-None-Match 304 path to the events and stats read endpoints

1 participant