Skip to main content

Get Dashboard Stats

Retrieves comprehensive dashboard statistics including project counts, status breakdowns, and recent projects for the authenticated user.

Headers

string
required
Bearer token for authentication

Response

boolean
Indicates if the request was successful
object
Aggregated statistics for all user projects
array
Array of the 4 most recently updated projects

Implementation Details

Query Logic

  • Fetches all projects owned by the authenticated user
  • Excludes projects with status deleted
  • Projects are sorted by updatedAt in descending order (most recent first)
  • Uses lean queries for optimal performance

Statistics Aggregation

  • totalProjects: Count of all non-deleted projects
  • liveCount: Filtered count where status === "live"
  • stoppedCount: Filtered count where status === "stopped"
  • staticCount: Filtered count where projectType === "Static" || projectType === "static"
  • nodeCount: Filtered count where projectType === "node"
  • totalRequests: Sum of totalRequest field across all projects using reduce

Recent Projects

  • Returns the first 4 projects from the sorted list (most recently updated)
  • Domain logic: displays custom domain if hascustomDomain is true, otherwise uses {subdomain}.deployhub.online format

Selected Fields

The query selects the following fields from the Project model:
  • name
  • projectType
  • status
  • totalRequest
  • totalBuilds
  • plan
  • subdomain
  • hascustomDomain
  • customDomain
  • createdAt
  • updatedAt

Error Response