0.1.4 • Published 4 months ago
auto-devops v0.1.4
AUTO DEVOPS
Health Check Setup
The health check module provides monitoring for your application's critical connections.
Installation
npm install auto-devops
Usage
import { createHealthCheck } from 'auto-devops';
// Initialize health checks
createHealthCheck({
app: app, // Express app instance
mongoConnection: mongoDb, // MongoDB connection
sqlConnection: sqlConnection, // SQL database connection
rabbitConnection: rabbitMqConnection // RabbitMQ connection
});
Configuration Options
Parameter | Type | Required | Description |
---|---|---|---|
app | Express.Application | Yes | Express application instance |
mongoConnection | mongoose.Connection | No | MongoDB connection object |
sqlConnection | Sequelize | No | SQL database connection |
rabbitConnection | amqp.Connection | No | RabbitMQ connection |
Endpoints
The health check creates the following endpoints:
GET /healthcheck
- Returns overall system health
Response Format
{
"status": "healthy",
"timestamp": "2025-03-05T05:44:26.589Z",
"mongodb": {
"status": "connected",
"type": "mongodb",
"database": "test_db",
"host": "172.0.0.1",
"port": 27017
},
"rabbitmq": {
"status": "connected",
"type": "rabbitmq",
"host": "172.20.6.22",
"port": 5672
},
"sql": {
"status": "connected",
"type": "sql",
"database": "test_db",
"host": "172.0.0.1",
"port": 3306,
"user": "dev"
},
"system": {
"cpu": 6.64,
"memory": {
"totalMemMb": 15666.14,
"freeMemMb": 3300.99,
"usedMemoryPercentage": 78.93
},
"storage": {
"totalStorageGb": 452.87,
"freeStorageGb": 140.9,
"usedStoragePercentage": 68.89
}
}
}
This health check implementation monitors your application's critical dependencies and provides real-time status information.