📌 Description
GET /api/v1/metrics/history in routes/metrics.ts returns the entire buffered BoundedHistory (history.all()) with no way to ask for only snapshots since a given point in time, forcing clients that poll infrequently to re-fetch and re-filter the whole (bounded, but potentially still sizeable) history every time.
🧩 Requirements and context
- Accept an optional
?since= ISO-8601 timestamp query param; return only snapshots with timestamp > since.
- Invalid (non-parseable)
?since= values return 400.
- Omitting
?since= preserves current full-history behavior.
🛠️ Suggested execution
- Modify
src/routes/metrics.ts's GET /history handler to parse and validate req.query.since (e.g. via new Date(...) + isNaN check, or a small helper in utils/validation.ts) and filter history.all() accordingly.
- Update
src/openapi.ts's /api/v1/metrics/history entry.
- Add tests in
src/routes/metrics.test.ts for a valid ?since=, an invalid one, and the omitted case.
✅ Acceptance criteria
🔒 Security notes
N/A — read-only filter over already-exposed metrics history.
📋 Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
📌 Description
GET /api/v1/metrics/historyinroutes/metrics.tsreturns the entire bufferedBoundedHistory(history.all()) with no way to ask for only snapshots since a given point in time, forcing clients that poll infrequently to re-fetch and re-filter the whole (bounded, but potentially still sizeable) history every time.🧩 Requirements and context
?since=ISO-8601 timestamp query param; return only snapshots withtimestamp > since.?since=values return 400.?since=preserves current full-history behavior.🛠️ Suggested execution
src/routes/metrics.ts'sGET /historyhandler to parse and validatereq.query.since(e.g. vianew Date(...)+isNaNcheck, or a small helper inutils/validation.ts) and filterhistory.all()accordingly.src/openapi.ts's/api/v1/metrics/historyentry.src/routes/metrics.test.tsfor a valid?since=, an invalid one, and the omitted case.✅ Acceptance criteria
GET /api/v1/metrics/history?since=<iso-timestamp>returns only snapshots after that time.?since=value returns 400 with a clear message.🔒 Security notes
N/A — read-only filter over already-exposed metrics history.
📋 Guidelines