- Enhanced Architecture: Modular design with proper separation of concerns
- Better Error Handling: Comprehensive validation with Zod
- Improved Logging: Structured JSON logging with configurable levels
- Security Features: CORS, rate limiting, security headers
- Monitoring: Prometheus metrics and health checks
- Configuration: Environment-based configuration management
Before (v1):
{
"status": "success",
"ok": true,
"code": 0,
"out": "review output"
}After (v2):
{
"status": "success",
"timestamp": "2024-03-01T10:00:00.000Z",
"request_id": "uuid-here",
"ok": true,
"code": 0,
"out": "review output",
"duration_ms": 5000
}Before (v1):
{
"status": "error",
"error": "Simple error message"
}After (v2):
{
"status": "error",
"error": "Detailed error message",
"timestamp": "2024-03-01T10:00:00.000Z",
"request_id": "uuid-here"
}Required environment variables (with defaults):
PORT=8787HOST=localhostNODE_ENV=developmentLOG_LEVEL=infoSCRIPT_PATH=./codereview.sh
GET /- API informationGET /health/live- Liveness probeGET /health/ready- Readiness probeGET /metrics- Prometheus metricsGET /metrics.json- JSON metrics
-
Update Environment Variables
cp .env.example .env # Edit .env with your configuration -
Update Client Code
- Handle new response format with
request_idandtimestamp - Update error handling for new error format
- Use new health check endpoints for monitoring
- Handle new response format with
-
Update Deployment
- Use new liveness/readiness probes
- Set up metrics collection
- Configure CORS if needed
-
Test Migration
# Start development server ./dev.sh # Test health check curl http://localhost:8787/health # Test API info curl http://localhost:8787/
The core functionality remains the same:
/reviewendpoint works as before (with enhanced responses)/review/nlendpoint works as before (with enhanced responses)/healthendpoint works as before (with additional information)
# .env file
PORT=8787
HOST=localhost
NODE_ENV=production
LOG_LEVEL=info
SCRIPT_PATH=./codereview.sh
RATE_LIMIT_REQUESTS=20
RATE_LIMIT_WINDOW_MS=60000
MAX_URLS=15
TIMEOUT_MS=600000
CORS_ORIGINS=https://yourdomain.com,https://api.yourdomain.com# prometheus.yml
scrape_configs:
- job_name: 'codereview-api'
static_configs:
- targets: ['localhost:8787']
metrics_path: '/metrics'HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8787/health/ready || exit 1- Request Timeouts: Configurable timeout for long reviews
- Rate Limiting: Prevents API abuse
- Structured Logging: Better debugging and monitoring
- Graceful Shutdown: Proper cleanup on termination
-
Invalid JSON responses
- Check that
Content-Type: application/jsonis set - Validate JSON payload format
- Check that
-
Rate limit errors
- Increase
RATE_LIMIT_REQUESTSorRATE_LIMIT_WINDOW_MS - Implement client-side retry logic
- Increase
-
Script execution failures
- Check
SCRIPT_PATHpoints to executable file - Verify script permissions with
ls -la codereview.sh
- Check
-
Log verbosity
- Set
LOG_LEVEL=debugfor detailed logging - Check server logs for error details
- Set
For issues or questions about migration:
- Check GitHub Issues: https://github.com/sychus/CodeReviewMCP/issues
- Review examples in
examples.ts - Use the development script:
./dev.sh