Petit-dom is a minimalist virtual DOM library optimized for minimal bundle size and high-performance diffing — it provides a lean, expressive API for building reactive UIs without the weight of larger frameworks. It's a natural fit for performance-critical apps and embedded widgets where every kilobyte matters. But a tiny virtual DOM can't protect you from a crashed backend, a failed deploy, or a silently broken data feed. Vigilmon provides continuous HTTP monitoring, heartbeat checks, and instant alerts so you know the moment something breaks — before your users do.
What You'll Build
- A
/healthendpoint for your Petit-dom Node.js backend - Vigilmon HTTP monitors for your app and API
- A heartbeat monitor for background jobs
- Alert channels (email and Slack)
- An uptime badge rendered in your Petit-dom UI
Prerequisites
- A Node.js project using Petit-dom (with Express or a plain HTTP server)
- A free Vigilmon account
Step 1: Add a Health Endpoint
Petit-dom handles client-side virtual DOM updates, but your server needs an HTTP health endpoint that Vigilmon can poll at regular intervals:
// server.js
import express from "express";
const app = express();
app.get("/health", async (req, res) => {
const checks = {};
let degraded = false;
// Database connectivity check
try {
// await db.query("SELECT 1");
checks.database = "ok";
} catch (err) {
checks.database = `error: ${err.message}`;
degraded = true;
}
// Cache check (e.g. Redis)
try {
// await redisClient.ping();
checks.cache = "ok";
} catch (err) {
checks.cache = `error: ${err.message}`;
degraded = true;
}
res.status(degraded ? 503 : 200).json({
status: degraded ? "degraded" : "ok",
timestamp: new Date().toISOString(),
checks,
});
});
// Serve your Petit-dom app's static assets
app.use(express.static("public"));
app.listen(process.env.PORT ?? 3000, () => {
console.log("Server running on port", process.env.PORT ?? 3000);
});
Test it locally:
curl http://localhost:3000/health | jq .
# {"status":"ok","timestamp":"2026-07-03T...","checks":{"database":"ok","cache":"ok"}}
Step 2: Configure Vigilmon HTTP Monitors
Log in to Vigilmon → Monitors → New Monitor:
Monitor 1: Petit-dom App (Frontend)
| Field | Value |
|---|---|
| URL | https://yourapp.com/ |
| Method | GET |
| Expected status | 200 |
| Expected body | A stable string from your HTML shell |
| Check interval | 1 minute |
Monitor 2: Health API
| Field | Value |
|---|---|
| URL | https://yourapp.com/health |
| Method | GET |
| Expected status | 200 |
| Expected body | "status":"ok" |
| Check interval | 1 minute |
Two independent monitors keep failure classes separate: a CDN outage (frontend down, API healthy) is distinct from a database failure (API degraded, frontend still cached).
Step 3: Heartbeat for Background Tasks
Petit-dom UIs often render data produced by background jobs — scheduled data fetches, cache refresh tasks, or aggregation pipelines. A Vigilmon heartbeat monitor detects when these jobs stop running silently:
// scheduler.js
import cron from "node-cron";
const VIGILMON_HEARTBEAT_URL = process.env.VIGILMON_HEARTBEAT_URL ?? "";
async function pingHeartbeat() {
if (!VIGILMON_HEARTBEAT_URL) return;
try {
await fetch(VIGILMON_HEARTBEAT_URL, { signal: AbortSignal.timeout(5000) });
} catch {
// Never let heartbeat errors crash the scheduler
}
}
// Run every 5 minutes for a real-time data pipeline
cron.schedule("*/5 * * * *", async () => {
try {
await refreshDataCache();
await pingHeartbeat(); // Only ping after successful execution
} catch (err) {
console.error("[scheduler] Data refresh failed:", err);
// No ping → Vigilmon alerts when the heartbeat window expires
}
});
async function refreshDataCache() {
// Pull fresh data for your Petit-dom views
}
Set up the heartbeat in Vigilmon:
- Monitors → New Heartbeat Monitor
- Set Expected interval to 10 minutes (2× the cron interval)
- Add the ping URL to your environment:
VIGILMON_HEARTBEAT_URL=https://vigilmon.online/api/heartbeat/xxxxxxxx
Step 4: Embed an Uptime Badge in Your Petit-dom UI
Petit-dom uses a hyperscript-style h function to build virtual nodes. You can include a Vigilmon status badge as a static vnode in your component tree:
// app.js (client-side with Petit-dom)
import h from "petit-dom";
const BADGE_URL = "https://vigilmon.online/api/badge/your-monitor-id.svg";
const STATUS_URL = "https://vigilmon.online/status/your-monitor-slug";
function App(data) {
return h("div", { class: "app" },
h("main", null, Content(data)),
h("footer", { class: "footer" },
h("a", {
href: STATUS_URL,
target: "_blank",
rel: "noopener noreferrer",
"aria-label": "Service uptime status",
},
h("img", {
src: BADGE_URL,
alt: "Uptime",
width: 120,
height: 20,
})
)
)
);
}
function Content(data) {
return h("p", null, data.message);
}
// Initial render
import { patch } from "petit-dom";
const container = document.getElementById("app");
let tree = App({ message: "Your content here." });
patch(container, tree);
// Update on data change
function update(data) {
const newTree = App(data);
patch(tree, newTree);
tree = newTree;
}
Petit-dom's efficient structural diffing means the static badge image node is never patched unless its attributes change — ideal for a status indicator that updates independently via the Vigilmon CDN.
Step 5: Set Up Alert Channels
In Vigilmon's Alert Channels settings:
Email Alerts
- Alert Channels → Email → add your on-call address
- Attach the channel to both HTTP monitors and the heartbeat monitor
Slack Alerts
- Create a Slack Incoming Webhook for your
#alertschannel - Alert Channels → Webhook → paste the Slack webhook URL
- Use this payload template:
{
"text": "🚨 *{{ monitor.name }}* is DOWN\n{{ monitor.url }}\nStatus: {{ event.status }}\n<https://vigilmon.online|Open Vigilmon>"
}
Step 6: Verify Everything Works
# 1. Confirm health endpoint returns 200
curl -s https://yourapp.com/health | jq .status
# 2. Simulate a failure — break your DB connection string and redeploy
# Expected: health endpoint returns 503; Vigilmon alerts within ~2 minutes
# 3. Remove the heartbeat URL and let the scheduler run one cycle
# Expected: heartbeat alert fires after the grace window expires
# 4. In Vigilmon → "Test Alert" to confirm Slack/email delivery
Summary
| Monitor | What It Catches | |---|---| | HTTP app check | CDN failures, broken static file serving | | HTTP health API | Database, cache, and external dependency failures | | Heartbeat | Scheduler crashes, silent data refresh failures |
Next Steps
- Create separate Vigilmon projects for staging and production
- Use Vigilmon's response time graphs to detect backend latency regressions alongside Petit-dom's render timing
- Configure escalating alerts: email for recoveries, Slack for active outages, PagerDuty for SLA-critical monitors
Ready to get started? Sign up for Vigilmon free — have your first monitor running in under 5 minutes.