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

@hotbunny/events

v0.1.0

Published

Events between HotBunny services on RabbitMQ: publish, subscribe with a durable queue per service, and a Postgres outbox.

Readme

@hotbunny/events

Events between HotBunny services on RabbitMQ.

  • One topic exchange (hotbunny.events) carries every event, routed by its type (account.updated, game.updated).
  • Each service has one durable quorum queue (<service>.events) bound to the types it listens to. Events that arrive while the service is down wait there.
  • A handler that throws gets the message again. After maxDeliveries (default 5) it goes to the service's dead-letter queue (<service>.events.dead) to be looked at.
  • Producers write events to an outbox table in the same transaction as the change; a relay sends them, so a change is never saved without its event.

Delivery is at least once: a handler can see the same event twice (same id) and events can arrive slightly out of order. Write handlers so that running one twice does no harm, for example by re-reading the current state instead of applying a delta.

Events

interface HotbunnyEvent<T> {
    id: string; // uuid, the same on every delivery
    type: string; // area.what-happened, lower case
    source: string; // the publishing service
    occurredAt: string; // ISO 8601
    data: T;
}

Subscribe

import { createEventBus } from "@hotbunny/events";

const bus = createEventBus({ url: process.env.RABBITMQ_URL!, service: "updater" });
bus.subscribe(["game.updated"], async (event) => {
    await syncGame((event.data as { gameId: number }).gameId);
});
await bus.start(); // reconnects by itself; starts even when the broker is down

Patterns follow AMQP topics: account.* is one word, game.# any number. Every subscribe() before start() adds bindings to the service's queue. A binding a service no longer asks for stays on the broker until it is removed there (management UI).

Publish through the outbox

Once per database:

import { outboxTableSql } from "@hotbunny/events";
await db.query(outboxTableSql()); // event_outbox

In the transaction that makes the change:

import { outboxRow } from "@hotbunny/events";
const row = outboxRow("game.updated", { gameId });
await tx.query("INSERT INTO event_outbox (id, type, data, occurred_at) VALUES ($1, $2, $3, $4)", [row.id, row.type, JSON.stringify(row.data), row.occurredAt]);

And the relay, beside the bus:

import { Pool } from "pg";
import { startOutboxRelay } from "@hotbunny/events";

const relay = startOutboxRelay({ bus, pool: new Pool({ connectionString: DATABASE_URL, max: 2 }) });
// after a commit, to send at once instead of within a second:
void relay.flush();

Rows are sent oldest first and marked sent after the broker confirms them. If sending fails the relay stops there and tries again on the next round. Sent rows are deleted after 7 days.

bus.publish(type, data) sends directly, without the outbox, for events that may be lost.

Tests

npm test runs the unit tests. With HOTBUNNY_EVENTS_TEST_URL=amqp://... (a throwaway vhost) it also runs against a real broker.