FREE TOOL

Health Check Generator

Pick your framework, toggle dependency checks, and get a production-ready/healthendpoint with liveness and readiness probes.

Framework

Configuration

Dependency Checks
Response Options
health-check.js64 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Health Check Endpoint
// Generated by TurboDeploy
// Endpoint: /health

400">const express = 400">require(300">'express');
400">const app = express();

app.get(300">'/health', 400">async (req, res) => {
  400">let status = 200;
  400">const results = {};

    results.uptime = process.uptime();
    results.version = 300">'1.0.0';
    results.timestamp = new Date().toISOString();

    // Database check
    400">try {
      400">const pool = 400">require(300">'./db'); // your db pool
      400">await pool.query(300">'SELECT 1');
      results.database = { status: 300">'ok', 400">type: 300">'postgresql' };
    } 400">catch (err) {
      results.database = { status: 300">'error', 400">type: 300">'postgresql' };
      status = 503;
    }

    // Redis check
    400">try {
      400">const redis = 400">require(300">'./redis'); // your redis client
      400">await redis.ping();
      results.redis = { status: 300">'ok' };
    } 400">catch (err) {
      results.redis = { status: 300">'error' };
      status = 503;
    }

    // Memory check
    400">const mem = process.memoryUsage();
    results.memory = {
      heapUsedMB: Math.round(mem.heapUsed / 1024 / 1024),
      heapTotalMB: Math.round(mem.heapTotal / 1024 / 1024),
      rssMB: Math.round(mem.rss / 1024 / 1024),
    };

  res.status(status).json({
    status: status === 200 ? 300">'healthy' : 300">'unhealthy',
    ...results,
  });
});

// Liveness probe (lightweight)
app.get(300">'/health/live', (req, res) => {
  res.status(200).json({ status: 300">'alive' });
});

// Readiness probe
app.get(300">'/health/ready', 400">async (req, res) => {
  400">try {
    400">const pool = 400">require(300">'./db');
    400">await pool.query(300">'SELECT 1');
    res.status(200).json({ status: 300">'ready' });
  } 400">catch {
    res.status(503).json({ status: 300">'not ready' });
  }
});

Health checks built into every deploy

TurboDeploy auto-configures liveness and readiness probes for your infrastructure.

Join Waitlist
FAQ

Frequently Asked Questions