tardis-machine
Version:
Locally runnable server with built-in data caching, providing both tick-level historical and consolidated real-time cryptocurrency market data via HTTP and WebSocket APIs
28 lines • 999 B
JavaScript
const BYTES_IN_MB = 1024 * 1024;
export const healthCheck = (_, res) => {
res.setHeader('Content-Type', 'application/json');
try {
const memUsage = process.memoryUsage();
const message = {
status: 'Healthy',
uptimeHours: Number((process.uptime() / (60 * 60)).toFixed(2)),
timestampMs: Date.now(),
memoryInfo: {
rssMB: Number((memUsage.rss / BYTES_IN_MB).toFixed(1)),
heapTotalMB: Number((memUsage.heapTotal / BYTES_IN_MB).toFixed(1)),
heapUsedMB: Number((memUsage.heapUsed / BYTES_IN_MB).toFixed(1)),
externalMB: Number((memUsage.external / BYTES_IN_MB).toFixed(1))
}
};
res.end(JSON.stringify(message));
}
catch {
if (!res.finished) {
res.statusCode = 500;
res.end(JSON.stringify({
message: 'Unhealthy'
}));
}
}
};
//# sourceMappingURL=healthCheck.js.map