Skip to content

[Backend] Add stream metrics endpoint #426

@ogazboiz

Description

@ogazboiz

https://t.me/+DOylgFv1jyJlNzM0

Description

There is no admin endpoint to observe the health and growth of the platform. A GET /admin/metrics endpoint returning aggregate stats (total streams, breakdown by status, total volume streamed) gives operators a quick pulse check and feeds future dashboards or alerting. This is a read-only DB aggregation query making it a well-scoped entry point for new contributors.

Acceptance Criteria

  • GET /api/v1/admin/metrics is implemented and registered in the admin router
  • Endpoint requires admin auth (existing admin middleware)
  • Response body shape:
    {
      "total_streams": 0,
      "active_streams": 0,
      "paused_streams": 0,
      "completed_streams": 0,
      "cancelled_streams": 0,
      "total_volume_streamed": "0"
    }
  • total_volume_streamed is the sum of withdrawn_amount across all streams (as a string to avoid JS number precision loss)
  • Results are cached for 60 seconds to avoid hammering the DB on repeated polls
  • Unit test mocks the repository and asserts the response shape and cache behaviour

Files to Touch

  • app/api/routes/v1/admin/metrics.ts — new route handler
  • app/api/routes/v1/admin/index.ts — register the route
  • app/repositories/stream.repository.ts — add getMetrics() aggregation query
  • tests/integration/admin/metrics.test.ts — new test file

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related tasksgood first issueGood for newcomers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions