JavaScript / TypeScript
Node.js & node-cron Monitoring
Add heartbeat monitoring to Node.js applications using node-cron, BullMQ, Agenda, or Bree.
1. Success Ping Setup
Ping when your job completes successfully Node.js — Success Ping
const cron = require('node-cron');
const https = require('https');
const PING_URL = 'https://cronhook.site/ping/YOUR_CHECK_ID';
cron.schedule('*/5 * * * *', async () => {
try {
await runBackupJob();
https.get(PING_URL);
} catch (err) {
https.get(`${PING_URL}/fail`);
console.error('Job failed:', err);
}
}); 2. Failure & Exception Handling
Ping /fail for instant failure dispatch without waiting for timeout Node.js — Failure Catch
// Fetch API (Node 18+)
async function ping(status = 'success') {
const url = status === 'fail'
? 'https://cronhook.site/ping/YOUR_CHECK_ID/fail'
: 'https://cronhook.site/ping/YOUR_CHECK_ID';
await fetch(url).catch(() => {});
} How to Implement in Node.js
1
Initialize Node.js scheduled job
Wrap your scheduled task inside node-cron, node-schedule, or BullMQ worker process.
2
Send HTTP ping on success
Call https.get() or fetch() to send a ping to CronHook when the task finishes execution.
3
Catch errors & ping /fail
Wrap your task in try/catch to send a failure ping to https://cronhook.site/ping/YOUR_CHECK_ID/fail for instant alert dispatch.
Pro-Tip for Node.js Developers
Node 18+ Global Fetch: Native fetch() requires zero external npm packages to ping CronHook.