npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@devbie/heartbeat-sdk

v1.2.1

Published

Framework-agnostic heartbeat client for installation liveness reporting

Readme

@devbie/heartbeat-sdk

npm version license node

A tiny, framework-agnostic heartbeat client for installation liveness reporting. Start it in any Node.js application and it will POST a ping to your heartbeat server immediately and then on a fixed interval.

  • Zero runtime dependencies — uses the global fetch available in Node.js 18 and later.
  • Idempotent singleton — calling startHeartbeat() twice returns the existing handle, so duplicate imports are safe.
  • Non-intrusive — the interval timer is unref()-ed so it never keeps the process alive, and network failures are silently swallowed.

Requirements

  • Node.js >= 18

Installation

npm install @devbie/heartbeat-sdk

Usage

import { startHeartbeat } from "@devbie/heartbeat-sdk";

const heartbeat = startHeartbeat({
  endpoint: "https://heartbeat.example.com/heartbeat/ping",
  token: process.env.HEARTBEAT_TOKEN!,
  appVersion: "1.4.2",
  env: "prod",
  instanceId: "ip-172-31-0-1",
});

// Later, if needed:
heartbeat.stop();

Options

startHeartbeat(options) takes the following configuration:

| Option | Type | Default | Required | Description | | ------------ | -------- | ------- | -------- | ---------------------------------------------------------------------------- | | endpoint | string | — | Yes | Full heartbeat report URL, e.g. https://host/heartbeat/ping. | | token | string | — | Yes | Installation token, sent as the X-Heartbeat-Token header; globally unique. | | intervalMs | number | 30000 | No | Heartbeat interval in milliseconds. | | appVersion | string | — | No | Deployed application version (git SHA or semver), self-reported. | | env | string | — | No | Self-reported deployment environment, e.g. prod. | | instanceId | string | — | No | Self-reported instance identifier (hostname, EC2 instance ID, ...). |

The returned HeartbeatHandle exposes:

| Method | Description | | -------- | --------------------------------------------------------- | | stop() | Stop the heartbeat loop and release the global singleton. |

Server contract

Each tick issues an HTTP request:

POST {endpoint}
X-Heartbeat-Token: {token}
Content-Type: application/json

endpoint is the full report URL (the SDK does not append any path).

The JSON body is omitted entirely when no optional metadata is supplied; otherwise it contains only the provided fields:

{
  "appVersion": "1.4.2",
  "env": "prod",
  "instanceId": "ip-172-31-0-1"
}

Because the installation token is globally unique, the server resolves the installation from the X-Heartbeat-Token header alone.

Security notes

This SDK is a liveness probe, not a remote operations channel. The following properties are verifiable in the source (a single ~90-line file, src/index.ts) and observable on the wire:

  • Outbound only — the SDK opens no listening port and accepts no inbound connections. Its only network activity is the outbound POST shown above.
  • No command channel — the server response carries only serverTime and reportIntervalSeconds, and the SDK does not read the response body. There is no mechanism for the server to push instructions to your process.
  • No data collection — the SDK reads no environment variables, files, process details, or network topology. The only payload fields are the ones your own configuration explicitly passes in (appVersion, env, instanceId), and all of them are optional.
  • Zero runtime dependencies — the entire trust surface is the single source file and the Node.js global fetch. Audit time is measured in minutes; pin the version or its tarball hash for supply-chain certainty.
  • Verifiable on the wire — the traffic is plain HTTP semantics; capture it with tcpdump or mitmproxy for 30 seconds to confirm exactly what leaves your network.
  • Token safety — the server stores only a SHA-256 hash of the installation token. Tokens can be rotated or revoked at any time, after which pings are rejected with 401.
  • Clean removal — deleting the startHeartbeat() call removes the integration completely: no resident process, no startup hooks, no leftover state.
  • Fail-safe — heartbeat network failures are silently swallowed and never crash or delay the host process.

If your policy still disallows reporting to an external endpoint, point endpoint at a heartbeat server inside your own network, or simply do not call startHeartbeat() — the SDK is fully opt-in.

Framework integrations

The SDK is framework-agnostic, but it is wired automatically into the project templates of the Devbie frameworks, gated behind two environment variables so unenrolled projects get a safe no-op:

  • Newbie (NestJS) template — main.ts starts the heartbeat when HEARTBEAT_ENDPOINT and HEARTBEAT_TOKEN are set.
  • Fewbie (Next.js) template — instrumentation.ts dynamically imports and starts it in the Node.js runtime only.
import { startHeartbeat } from "@devbie/heartbeat-sdk";

const endpoint = process.env.HEARTBEAT_ENDPOINT;
const token = process.env.HEARTBEAT_TOKEN;
if (endpoint && token) {
  startHeartbeat({ endpoint, token });
}

Related packages

License

MIT