Elysia.js is a fast TypeScript framework for Bun runtime. If you're building APIs with Elysia, here's how to add uptime monitoring and heartbeat checks with Vigilmon.
Step 1: Add a Health Check Route to Elysia
import { Elysia } from 'elysia';
const app = new Elysia()
.get('/health', () => ({
status: 'ok',
timestamp: Date.now(),
runtime: 'bun'
}))
.get('/api/users', () => getUsers())
.listen(3000);
console.log(`Server running at http://${app.server?.hostname}:${app.server?.port}`);
Step 2: Enhanced Health Check with Database Connectivity
const app = new Elysia()
.get('/health', async ({ set }) => {
const checks: Record<string, boolean> = {
server: true,
database: false,
};
try {
await db.execute('SELECT 1');
checks.database = true;
} catch {}
const allHealthy = Object.values(checks).every(Boolean);
set.status = allHealthy ? 200 : 503;
return {
status: allHealthy ? 'ok' : 'degraded',
checks,
timestamp: Date.now(),
};
})
.listen(3000);
If the database is down, this returns 503 and Vigilmon alerts your team.
Step 3: Set Up Vigilmon Monitoring
- Go to vigilmon.online
- Create a new HTTP monitor
- URL:
https://your-elysia-api.com/health - Check interval: 1 minute
- Multi-region: enabled
Step 4: Heartbeat Monitoring for Background Tasks
// src/tasks/daily-cleanup.ts
const HEARTBEAT_URL = process.env.VIGILMON_HEARTBEAT_URL;
export async function runDailyCleanup() {
try {
await deleteOldSessions();
await archiveExpiredOrders();
if (HEARTBEAT_URL) {
await fetch(HEARTBEAT_URL).catch(() => {});
}
} catch (error) {
console.error('Cleanup failed:', error);
// No heartbeat = Vigilmon alerts
}
}
Create a heartbeat monitor with a 25-hour period for daily tasks.
Elysia on Bun + Docker
FROM oven/bun:1 as base
WORKDIR /app
COPY package*.json bun.lockb ./
RUN bun install --frozen-lockfile
COPY . .
EXPOSE 3000
CMD ["bun", "src/index.ts"]
After deploying to Fly.io, Railway, or Render, add a Vigilmon monitor pointing to your production URL.
What Vigilmon Catches for Elysia
| Issue | Detected by |
|---|---|
| Bun process crashed | Connection refused |
| Unhandled exception | Brief downtime detected |
| Database connection lost | 503 from health endpoint |
| OOM kill | Downtime detected |
| Regional network issue | Multi-region cross-check |
Summary
- Add a
/healthroute to your Elysia app - Check database connectivity (return 503 if DB is down)
- Create a Vigilmon HTTP monitor for the health endpoint
- Add heartbeat monitoring for scheduled background tasks
- Set up Slack/email alerts
Elysia + Bun is fast. Keep it reliable with Vigilmon.
Vigilmon — uptime and heartbeat monitoring for Elysia.js, Hono, Fastify, and every Bun API. Free plan available.
Top comments (0)