Skip to content

feat(api/observability): paginated history, meter notes CRUD, Prometheus labels, adminAuth hardening, usage event retention - #660

Merged
Dev-AdeTutu merged 2 commits into
Dev-AdeTutu:mainfrom
Mozez155:main
Jul 30, 2026
Merged

feat(api/observability): paginated history, meter notes CRUD, Prometheus labels, adminAuth hardening, usage event retention#660
Dev-AdeTutu merged 2 commits into
Dev-AdeTutu:mainfrom
Mozez155:main

Conversation

@Mozez155

Copy link
Copy Markdown
Contributor

Summary

Build fixes included

Several pre-existing merge-conflict residues across index.ts, routes/stats.ts, routes/payments.ts, routes/webhooks.ts, lib/stellar.ts, and iot/bridge.ts were resolved as part of making npm run build pass (DoD requirement for all four issues).

Test plan

  • npm run build passes (verified locally)
  • GET /api/meters/:id/history?pageSize=0 returns 400
  • GET /api/meters/:id/history?pageSize=20 returns paginated envelope with total and hasMore
  • POST /api/meters/:id/notes with X-Admin-Key creates note; GET /api/meters/:id/notes returns it; DELETE /api/meters/:id/notes/:noteId removes it
  • DELETE /api/usage-events?olderThanDays=30 returns { deletedCount: N }
  • GET /api/usage-events/failed returns paginated failed events
  • POST /api/usage-events/:id/replay resets a failed event to pending
  • Server refuses to start when ADMIN_API_KEY is unset
  • GET /metrics exposes solargrid_usage_events_total{status="pending"} etc.

closes #646
closes #647
closes #648
closes #651

…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
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@Dev-AdeTutu

Copy link
Copy Markdown
Owner

Pls fix conflicts

@Dev-AdeTutu
Dev-AdeTutu merged commit c14fc45 into Dev-AdeTutu:main Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment