Skip to content

Health Check & System Monitoring Module #176

@mftee

Description

@mftee

Description:

Implement a HealthModule that exposes comprehensive health check and readiness endpoints so that infrastructure tools (load balancers, Kubernetes probes, uptime monitors) can verify system status.

Requirements:

  • Install @nestjs/terminus
  • Create a HealthController with:
    • GET /api/health — liveness probe (returns 200 OK with { status: "ok" } if the process is running)
    • GET /api/health/ready — readiness probe that checks:
      • PostgreSQL connectivity (via TypeORM DataSource)
      • Disk space (warn if less than 500MB free)
    • GET /api/health/detailed — full status including DB response time, disk usage, Node.js memory usage (process.memoryUsage()), and uptime
  • Create a SystemMetricsService with:
    • getMemoryUsage() — returns { heapUsed, heapTotal, rss } in MB
    • getUptime() — returns process uptime in seconds
    • getDiskUsage() — checks free space on the upload directory
  • The readiness endpoint must return 503 if any critical check fails

Acceptance Criteria:

  • GET /api/health always returns 200 (pure liveness — never fails)
  • GET /api/health/ready returns 503 when the DB is unreachable
  • Unit tests mock the DB check and disk check
  • Swagger docs on all three endpoints

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions