Skip to content

feat(backend): add POST /api/meters/batch accepting array of {meter_id, owner} pairs#501

Open
adamsithr wants to merge 2 commits into
Dev-AdeTutu:mainfrom
adamsithr:feat-batch-register
Open

feat(backend): add POST /api/meters/batch accepting array of {meter_id, owner} pairs#501
adamsithr wants to merge 2 commits into
Dev-AdeTutu:mainfrom
adamsithr:feat-batch-register

Conversation

@adamsithr

@adamsithr adamsithr commented Jul 8, 2026

Copy link
Copy Markdown

Summary

This PR implements a consolidated set of backend features and fixes, resolving multiple open issues in the Stellar Wave Program:

  1. Batch Meter Registration: Added POST /api/meters/batch to register multiple meters at once (Closes feat(backend): add POST /api/meters/batch-register accepting array of {meter_id, owner} pairs #445).
  2. Inactive Meters Audit: Added GET /api/meters/inactive listing dormant meters with their last active timestamp queried from the local SQLite database (Closes feat(backend): add GET /api/meters/inactive returning meters where active=false with last_used timestamp #446).
  3. Webhooks Listing: Added GET /api/webhooks endpoint returning all registered low-balance webhook URLs (Closes feat(backend): add GET /api/webhooks endpoint listing all registered low-balance webhook URLs #444).
  4. X-Request-ID Propagation: Integrated requestContext.ts with requestLogger middleware to run the request lifecycle under AsyncLocalStorage and set/propagate the X-Request-ID header on all responses (Closes feat(backend): propagate X-Request-ID header on all responses using requestContext.ts #443).
  5. Deactivation MQTT Signal: Emits an immediate MQTT OFF control message when a meter is deactivated via POST /api/meters/:id/deactivate to bypass Soroban contract polling latency (Closes feat(backend): emit MQTT message when a meter is deactivated via POST /api/meters/:id/deactivate #442).

Changes

  • Backend API Routes: Implemented the routes in backend/src/routes/meters.ts and backend/src/routes/webhooks.ts.
  • Request Context Middleware: Updated backend/src/middleware/requestLogger.ts.
  • Unit Tests: Created focused Vitest suites for the new endpoints:
    • backend/tests/meters-inactive.test.ts
    • backend/tests/webhooks.test.ts
    • backend/tests/request-id.test.ts
    • backend/tests/meters-deactivate.test.ts
  • Node Compatibility: Fixed the local better-sqlite3 native binary version mismatch to ensure clean test suite execution.

All tests are passing successfully locally. Ready for review!

@adamsithr

Copy link
Copy Markdown
Author

Hi there! 👋 Just a gentle ping on this PR. Let me know if there's any feedback or if anything else is needed from my end to get this reviewed so we can close out the bounty. Thanks!

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