Registry / messaging / pp-event-bus

pp-event-bus

JSON →
library1.12.1jsnpmunverified

A distributed event bus library for TypeScript and JavaScript, built on Redis Streams. Version 1.12.1 supports event versioning, metadata, validation, and a fanout (1:N) pattern. It uses a modular architecture with separate components for stream management, publishing, consumer groups, and logging. The library is designed for high-performance event distribution with consumer groups for reliable message delivery and load balancing. Key differentiators include built-in validation hooks, semantic versioning for events, and optional JSONL persistence. It is actively maintained and released on npm.

npm install pp-event-bus
INSTALL
IMPORT
SIG · PP-EVENT-BUS
P
pp-event-bus
messagingjavascriptv1.12.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Event
import { Event } from 'pp-event-bus'
import Event from 'pp-event-bus'
Event is a named export, not a default export.
EventBus
import { EventBus } from 'pp-event-bus'
const EventBus = require('pp-event-bus').EventBus
ESM named import is preferred; CommonJS require also works but is non-standard.
EventBusConfig
import { EventBusConfig } from 'pp-event-bus'
Config class for initializing EventBus.

Shows how to define a custom event with validation, configure an EventBus with Redis URL from environment, and publish an event.

import { Event, EventBus, EventBusConfig } from 'pp-event-bus'; class OrderCreatedEvent extends Event { constructor( public readonly orderId: string, public readonly customerId: string, public readonly totalAmount: number ) { super('1.0.0'); this.validate(); } protected validate(): void { if (this.totalAmount <= 0) { throw new Error('Amount must be greater than 0'); } } } const config = new EventBusConfig({ redisUrl: process.env.REDIS_URL ?? 'redis://localhost:6379', logger: console }); const eventBus = new EventBus(config); async function main() { const event = new OrderCreatedEvent('123', '456', 100); await eventBus.publish('order.created', event); console.log('Event published'); } main().catch(console.error);
Debug
Known issues
breakingThe 'EventBusConfig' constructor now requires 'redisUrl' as a string (not a Redis client object).
fix
Pass a Redis URL string instead of a client instance.
affects: >=1.0.0
deprecatedThe 'Event.publish()' method is deprecated in favor of 'EventBus.publish()'.
fix
Use eventBus.publish(topic, event) instead of event.publish()
affects: >=1.5.0
gotchaThe 'Event' class requires a call to 'this.validate()' in the constructor if you override the 'validate' method, otherwise validation will not run.
fix
Always call super() and this.validate() in your custom event constructor.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Event is not a constructor
Importing Event as default instead of named export.
fix
Use import { Event } from 'pp-event-bus' instead of import Event from 'pp-event-bus'.
Error: Amount must be greater than 0
Validation error when creating an OrderCreatedEvent with a non-positive totalAmount.
fix
Ensure totalAmount > 0 when creating the event.
TimeoutError: command timed out
Redis connection failure or network issue.
fix
Check Redis URL and ensure Redis server is reachable.
Upgrade
Version history
1.12.1latest on npm
Audit
Dependencies
redisrequiredRedis client for connecting to Redis/DragonflyDB
Agent activity
14 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources
pp-event-bus — npm install pp-event-bus · libregistry