Skip to content

chore: add health check endpoint and structured logging to backendΒ #406

@ryzen-xp

Description

@ryzen-xp

πŸ“ Description

Add a /health endpoint for uptime monitoring and configure structured JSON logging so backend logs are parseable in production. Both are necessary before any deployment.

βœ… Requirements

  • Install @nestjs/terminus and create HealthModule
  • Implement GET /health that checks: HTTP server status, PostgreSQL connection, Stellar RPC reachability
  • Each health indicator returns { status: 'up' | 'down', details?: object }
  • Overall response is 200 when all healthy, 503 when any indicator is down
  • Install nestjs-pino or winston for structured JSON logging
  • Replace default NestJS logger with structured logger
  • Every log line includes: timestamp, level, context (module name), message
  • Log all incoming requests with method, path, statusCode, and response time
  • Add LOG_LEVEL env var (default: info)

🎯 Acceptance Criteria

  • GET /health returns correct status for all three indicators
  • Returns 503 when database is unreachable
  • All logs are valid JSON in production mode
  • Request logs include method, path, status, and duration
  • LOG_LEVEL env var controls verbosity

πŸ“ Expected files to change/structure

  • backend/src/health/health.module.ts
  • backend/src/health/health.controller.ts
  • backend/src/main.ts
  • backend/.env.example (add LOG_LEVEL)

Commit: chore: add health check endpoint and structured logging to backend
Branch: chore/backend-health-and-logging | Priority: LOW | Difficulty: one-coffee

Metadata

Metadata

Assignees

Labels

stellar waveThis issue listed on Drip stellar wave contest

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions