Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

🖥️ Home Server Monitor

Monitors a home server and sends a Pushcut notification if it goes offline.

How it works

  1. The home server pings POST /heartbeat every 15 minutes with a secret key
  2. monitor.ts runs every 15 minutes and checks if a heartbeat has been received in the last hour
  3. If not, a Pushcut notification is sent via NOTIFY_SERVER_DOWN_URL
  4. The status page at / renders the current state server-side — no client-side JS

Setup

Environment variables

VariableDescription
SECRET_KEYRequired on all heartbeat requests via x-secret-key header
NOTIFY_SERVER_DOWN_URLPushcut webhook URL to call when the server is down

Heartbeat cron job

Add this to your home server's crontab:

*/15 * * * * curl -X POST https://halffullheartbeat.val.run/heartbeat -H "x-secret-key: YOUR_SECRET_KEY"

Files

  • main.ts — Hono HTTP server; serves the status page and accepts heartbeats
  • monitor.ts — Interval val that checks for downtime and triggers notifications