@skypulsefy/pulse
v0.1.4
Published
Official Skypulsefy Pulse client for sending heartbeat pings
Maintainers
Readme
@skypulsefy/pulse
Official Skypulsefy Pulse client for sending heartbeat pings. API host is fixed to https://skypulsefy.com
The client auto-measures roundtrip latency via GET /api/ping and sends that ms with the heartbeat to POST /api/ping/:pageId/:serviceId. Minimal setup: only apiKey, pageId, serviceId.
Install
npm install @skypulsefy/pulseQuick start
import { keepAlive } from '@skypulsefy/pulse';
keepAlive({
apiKey: process.env.SKYPULSEFY_API_KEY,
pageId: 'my-page',
serviceId: 'web',
// optional:
// intervalMs: 60_000,
// debug: true,
// onPing: ({ ms, status }) => console.log('sent ms', ms, 'status', status)
});Or manage the client yourself:
import SkypulsefyClient from '@skypulsefy/pulse';
const client = new SkypulsefyClient({
apiKey: process.env.SKYPULSEFY_API_KEY,
pageId: 'my-page',
serviceId: 'web',
debug: true,
msProvider: async () => 42,
onPing: (info) => console.log(info),
// If you need to send ms to the server (legacy):
// useLegacyPingMs: true
});
client.start();
// later
client.stop();Environment variable SKYPULSEFY_BASE_URL can override the API base URL.
