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

tabletcommand-backend-heartbeat

v3.3.0

Published

Tablet Command Heartbeat

Readme

tabletcommand-backend-heartbeat

A shared library for logging and retrieving heartbeat events from CAD system integrations. It is not a server — consuming backend services import it, inject a Redis client, and call its functions.

How it works

Consuming service (HTTP handler / queue consumer)
  └─ calls log() or logInterfaceVersion()
       └─ domain.ts: calculates delay, builds StoredHeartbeat
            └─ store.ts: LPUSH to Redis list (capped at 25 items via LTRIM)

Usage

import indexModule from "tabletcommand-backend-heartbeat";

const heartbeat = indexModule({ client: redisClient });

// Record a heartbeat from an incoming CAD message
await heartbeat.log(department, message, "incident");

// Record the CAD interface version
await heartbeat.logInterfaceVersion(department, message, "incident");

// Read back heartbeat state for a department
const state = await heartbeat.checkDepartment(department);
// state: { incident: EnhancedHeartbeat[], status: EnhancedHeartbeat[], location: EnhancedHeartbeat[], version: string }

Public API

| Function | Description | |---|---| | log(department?, message?, type?) | Record a heartbeat event | | conditionalLog(shouldLog, department?, message?, type?) | Conditionally record | | logInterfaceVersion(department, message, type) | Record CAD interface version string | | checkDepartment(dept) | Read heartbeat state for one department | | checkDepartments(depts) | Read heartbeat state for multiple departments | | defaultMessage(atDate?) | Create a blank HeartbeatMessage |

type is one of "incident", "status", or "location".

Input message types

HeartbeatMessage — periodic health check from a CAD interface:

{
  Time: string;       // ISO datetime of the heartbeat
  Status: string;     // e.g. "OK", "Green"
  Message: string;    // Human-readable description
  Interface?: string; // Version string, e.g. "Interface_Two_Way 1.7.5"
}

IncidentMessage — data push from a CAD system:

{
  IncidentNumber: string;
  EntryDateTime?: string;
  ClosedDateTime?: string;
  Interface?: string;
  Unit?: Array<{
    TimeDispatched?: string; TimeEnroute?: string; TimeArrived?: string;
    TimeCleared?: string;    TimeAtHospital?: string; TimePatient?: string;
    TimeStaged?: string;     TimeTransport?: string; TimeTransporting?: string;
  }>;
  Comment?: Array<{ CommentDateTime?: string }>;
}

Timestamp resolution order (highest valid timestamp wins):

TimeEntryDateTimeClosedDateTime → unit timestamps → CommentDateTime → fallback (-7200, marked invalid)

Redis schema

No MongoDB is used. All state lives in Redis.

Heartbeat lists — hb:{t}:{departmentId}

| Key | Type description | |---|---| | hb:i:{departmentId} | Incident heartbeats | | hb:s:{departmentId} | Status heartbeats | | hb:l:{departmentId} | Location heartbeats |

Redis type: List. Max 25 entries per key (enforced via LTRIM on every write). Each entry is a JSON-serialised StoredHeartbeat:

{
  "RcvTime": 1693355267,
  "Delay": 33,
  "H": 1,
  "src": "hb",
  "v": true
}

| Field | Description | |---|---| | RcvTime | Unix timestamp (seconds) when the message was received | | Delay | Seconds between the message's own timestamp and receive time | | H | 1 = heartbeat message, 0 = incident message | | src | Source tag, e.g. "hb", "FC-1234-entry", "FC-1234-commentDate" | | v | true if the resolved timestamp was valid |

Interface version — cad:v:{departmentId}

Redis type: String. Stores the cleaned CAD interface version extracted from Interface field, e.g. "Interface_Two_Way 1.7.5".

Development

npm run build   # compile TypeScript
npm run lint    # ESLint
npm run test    # node:test suite