feat(api/observability): paginated history, meter notes CRUD, Prometheus labels, adminAuth hardening, usage event retention - #660
Merged
Conversation
…bels, adminAuth hardening, usage event retention and replay - Dev-AdeTutu#646: Remove adminAuth silent bypass; add ADMIN_API_KEY to REQUIRED_ENV for startup fatal; accept X-Admin-Key header; log failed auth attempts with source IP; add entropy note to .env.example - Dev-AdeTutu#647: Add purgeSubmittedUsageEvents, getFailedUsageEvents, replayFailedUsageEvent to usageEvents.ts; emit structured error log on failed transition; register /api/usage-events router; add status/submitted_at index migration - Dev-AdeTutu#648: Wire dimensional labels (topic, plan, meter_id, status, attempt) already defined in metrics.ts into bridge.ts, usageEvents.ts, webhookRegistry.ts; add MqttPayloadSchema to validation.ts; fix all TypeScript compile errors blocking the build - Dev-AdeTutu#651: Add author_ip to meter_notes table (with ALTER TABLE migration); expose GET/POST/DELETE /api/meters/:id/notes CRUD endpoints; update history default to 20 with 400 validation; update openapi.yaml for all new endpoints closes Dev-AdeTutu#646 closes Dev-AdeTutu#647 closes Dev-AdeTutu#648 closes Dev-AdeTutu#651
|
@Mozez155 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Owner
|
Pls fix conflicts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
adminAuthno longer silently bypasses the guard whenADMIN_API_KEYis unset — server now exits at startup (added toREQUIRED_ENV);X-Admin-Keyaccepted alongsideAuthorization: Bearer; failed auth attempts logged atwarnwith source IP (key never logged); entropy note added to.env.example.DELETE /api/usage-events?olderThanDays=N), dead-letter inspection (GET /api/usage-events/failed), and replay (POST /api/usage-events/:id/replay) implemented inusageEvents.tsand registered inindex.ts; failed transition now emits structurederror-level Pino log.topicon MQTT counter,planon payment volume,meter_idon active-meters gauge,status+attempton webhook deliveries,statuson usage events). Fixed missingusageEventsimport andMqttPayloadSchemathat were blocking the build.GET /api/meters/:id/historynow validatespage/pageSizeand returns 400 on bad values (default 20, max 100). NewGET/POST/DELETE /api/meters/:id/notesCRUD endpoints withauthor_ipstorage and SQLite migration. OpenAPI updated for all endpoints.Build fixes included
Several pre-existing merge-conflict residues across
index.ts,routes/stats.ts,routes/payments.ts,routes/webhooks.ts,lib/stellar.ts, andiot/bridge.tswere resolved as part of makingnpm run buildpass (DoD requirement for all four issues).Test plan
npm run buildpasses (verified locally)GET /api/meters/:id/history?pageSize=0returns 400GET /api/meters/:id/history?pageSize=20returns paginated envelope withtotalandhasMorePOST /api/meters/:id/noteswithX-Admin-Keycreates note;GET /api/meters/:id/notesreturns it;DELETE /api/meters/:id/notes/:noteIdremoves itDELETE /api/usage-events?olderThanDays=30returns{ deletedCount: N }GET /api/usage-events/failedreturns paginated failed eventsPOST /api/usage-events/:id/replayresets a failed event to pendingADMIN_API_KEYis unsetGET /metricsexposessolargrid_usage_events_total{status="pending"}etc.closes #646
closes #647
closes #648
closes #651