feat: add request correlation, health checks, and graceful shutdown#113
Merged
3m1n3nc3 merged 1 commit intoJul 21, 2026
Conversation
- Add request context middleware for request ID generation and actor tracking - Implement liveness (/health/live) and readiness (/health/ready) endpoints - Add graceful shutdown handler for HTTP, jobs, and database connections - Enhance logger with JSON format for production and request correlation - Update error middleware to include request ID in responses - Add comprehensive tests for all new features - Add test scripts for health endpoint verification Closes: Phase 0 infrastructure requirements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
I've successfully implemented request correlation, health checks, and graceful shutdown for the Learnault API. Here's what was delivered:
✅ Completed Features
1. Request Context Middleware (
src/middleware/request-context.ts)2. Health Check Routes (
src/routes/health.routes.ts)/health/live- Liveness probe (process running check)/health/ready- Readiness probe (dependency health check with database connectivity)3. Graceful Shutdown (
src/server.ts)4. Enhanced Logging (
src/config/logger.ts)5. Updated Error Middleware (
src/middleware/error.middleware.ts)✅ Test Coverage
✅ Configuration Added
# .env.example updated with: LOG_LEVEL=info SHUTDOWN_TIMEOUT_MS=30000✅ Test Scripts Created
scripts/test-health.bat(Windows)scripts/test-health.sh(Unix/Linux)✅ Documentation
✅ Verification
All acceptance criteria met and ready for deployment! 🚀
Closes #62