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

@vytches/ddd-messaging

v0.28.0

Published

Outbox pattern and reliable message delivery

Readme

@vytches/ddd-messaging

npm version TypeScript License: MIT

Transactional Outbox pattern for reliable domain event delivery

Provides the Outbox pattern — store-then-publish guarantee for domain events. This package contains only Outbox infrastructure. There is no Saga support.

Installation

pnpm add @vytches/ddd-messaging

What's included

| Export | Kind | Description | | ------------------------ | -------------- | --------------------------------------------------------------- | | MessageStatus | enum | PENDING \| PROCESSING \| PROCESSED \| FAILED | | MessagePriority | enum | LOW \| NORMAL \| HIGH \| CRITICAL | | OutboxMessageFactory | class | Creates IOutboxMessage instances | | OutboxProcessor | class | Polls the repository and dispatches messages | | EventBusOutboxHandler | class | IOutboxMessageHandler that publishes to an IEventBus | | OutboxService | class | High-level facade: store, schedule, and coordinate processing | | IOutboxRepository | abstract class | Base repository contract — extend this for your storage backend | | IOutboxMessage | interface | Message shape with id, payload, status, priority, timestamps | | IOutboxMessageHandler | interface | Single-method handler: handle(message): Promise<void> | | OutboxMiddleware | type | Middleware signature for the processor pipeline | | OutboxProcessorOptions | interface | Processor configuration (interval, batch size, retries…) | | OutboxServiceOptions | interface | Service configuration | | OutboxMessageOptions | interface | Per-message options (priority, processAfter…) | | RetryBackoffConfig | interface | Exponential backoff configuration for the processor |

Quick start

import {
  OutboxService,
  OutboxProcessor,
  OutboxMessageFactory,
  EventBusOutboxHandler,
  MessagePriority,
} from '@vytches/ddd-messaging';
import { UnifiedEventBus } from '@vytches/ddd-events';

// Implement IOutboxRepository for your storage (e.g. PostgreSQL)
class PostgresOutboxRepository extends IOutboxRepository {
  async save(message) {
    /* ... */
  }
  async findPending(limit) {
    /* ... */
  }
  async markProcessed(id) {
    /* ... */
  }
  async markFailed(id, error) {
    /* ... */
  }
}

const repository = new PostgresOutboxRepository();
const eventBus = new UnifiedEventBus();

// Service stores messages, processor dispatches them
const service = new OutboxService(repository);
const handler = new EventBusOutboxHandler(eventBus);
const processor = new OutboxProcessor(repository, handler, {
  processingInterval: 5_000,
  batchSize: 50,
  maxRetries: 3,
});

// Store a message (call this inside your aggregate save transaction)
const factory = new OutboxMessageFactory();
const message = factory.create({
  messageType: 'OrderCreated',
  payload: { orderId: '123' },
  priority: MessagePriority.HIGH,
});
await service.store(message);

// Start polling
await processor.start();

Custom message handler

Implement IOutboxMessageHandler to route messages any way you like:

import { IOutboxMessageHandler, IOutboxMessage } from '@vytches/ddd-messaging';

class KafkaMessageHandler implements IOutboxMessageHandler {
  async handle(message: IOutboxMessage): Promise<void> {
    await kafkaProducer.send({
      topic: message.messageType,
      messages: [{ value: JSON.stringify(message.payload) }],
    });
  }
}

Implement your repository

Extend IOutboxRepository and provide persistence:

import {
  IOutboxRepository,
  IOutboxMessage,
  MessageStatus,
} from '@vytches/ddd-messaging';

class MyOutboxRepository extends IOutboxRepository {
  async save(message: IOutboxMessage): Promise<void> {
    await db.outbox.insert(message);
  }

  async findPendingMessages(limit: number): Promise<IOutboxMessage[]> {
    return db.outbox.findWhere({ status: MessageStatus.PENDING }, limit);
  }

  async markAsProcessed(id: string): Promise<void> {
    await db.outbox.update(id, { status: MessageStatus.PROCESSED });
  }

  async markAsFailed(id: string, error: string): Promise<void> {
    await db.outbox.update(id, {
      status: MessageStatus.FAILED,
      lastError: error,
    });
  }
}

Package boundaries

@vytches/ddd-messaging depends on:

  • @vytches/ddd-contractsIDomainEvent, IEventBus
  • @vytches/ddd-logging — internal structured logging

Note on Sagas

This package has no Saga support. For long-running process orchestration, use a dedicated library (e.g. Temporal, Conductor).

License

MIT