API + Health Monitor + Dashboard (for ghaymah.systems)
This is your uploaded project (server.js, monitor.sh, index.html,
Dockerfile) with three functional bugs fixed and a couple of production
hardening tweaks. Nothing about your architecture changed.
What was wrong and what I changed
-
index.htmlwas fetching the wrong URL.const API_URL = "";thenfetch(API_URL)calls the current page (/), not/health— so it was trying toJSON.parse()an HTML page and always fell into thecatchblock ("Offline"), even when the API was healthy. Fixed tofetch('/health'). -
server.jshad no route servingindex.html. The dashboard needs to be reachable somewhere. I addedexpress.static('public')and movedindex.htmlintopublic/, so the dashboard is served at/and the plain-text welcome message moved to/apiso the two don't collide. -
monitor.shreferenced$response_time, which was never set — the response-time column was always empty. Fixed by measuring it directly withcurl -w "%{time_total}". Also added a fallback JSON parser for whenjqisn't installed, and an optional CSV log file. -
Dockerfile ran
npm init -y && npm installon every build, with no lockfile/manifest — slow, non-reproducible, and re-downloads dependencies on every rebuild even if nothing changed. Added a realpackage.jsonand splitCOPY package.jsonfromCOPY server.jsso Docker caches thenpm installlayer. Also switchednode:20-alpine3.16(an older, unsupported Alpine point release) tonode:20-alpine(current supported tag).
Files
.
├── Dockerfile
├── package.json
├── server.js
├── public/
│ └── index.html ← dashboard, served at /
└── monitor.sh ← external checker, run it against the deployed URL
Run locally
npm install
npm start
# open http://localhost:3000 -> dashboard
# open http://localhost:3000/health -> raw JSON
In another terminal, point the monitor at it:
chmod +x monitor.sh
./monitor.sh http://localhost:3000 30
Build & run with Docker
docker build -t api-health-demo .
docker run -d -p 3000:3000 --name api-health-demo api-health-demo
/health response shape
{
"status": "Online",
"uptime_seconds": 42,
"request_count": 17,
"response_time_ms": 3,
"timestamp": "2026-07-27T20:10:00.000Z"
}
Deploy to ghaymah.systems
See DEPLOY_GHAYMAH.md for the step-by-step (build → push → create
service → set port 3000 → point monitor.sh at the live URL).