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

@thuo-huynh/module-queue-core

v0.1.0

Published

A provider-agnostic queue abstraction library for Kafka (and future brokers). Standardizes producer, consumer, retry, DLQ, and observability patterns.

Downloads

9

Readme

module-queue

A provider-agnostic queue abstraction library for Node.js and TypeScript. Standardizes producer, consumer, retry, DLQ, and observability patterns — starting with Kafka.

npm version CI License: MIT

Why module-queue?

Building Kafka producers and consumers directly in each service leads to:

  • Duplicated retry logic across teams
  • Inconsistent error handling
  • Missing DLQ support
  • No standard for correlation ID propagation
  • Tight coupling to KafkaJS internals

module-queue solves this by providing a unified, opinionated abstraction that works with Kafka today and is ready for other brokers (RabbitMQ, etc.) in the future.

Features

  • Producer — publish single or batch messages with automatic header enrichment
  • Consumer — subscribe to topics with graceful shutdown and manual commit
  • Retry — exponential backoff, linear, or custom retry strategies
  • DLQ — automatic dead-letter queue handling after max retries
  • Correlation IDs — distributed tracing headers injected on every message
  • Config — environment variable or programmatic configuration
  • Topic naming — conventions for consistent topic naming across services
  • TypeScript-first — full type safety and IntelliSense support

Installation

npm install @module-queue/core kafkajs

kafkajs is a required peer dependency.

Quick Start

import {
  KafkaProvider,
  createQueueConfig,
  ExponentialBackoffRetry,
  KafkaDLQHandler,
  TopicNaming,
} from '@module-queue/core';

// 1. Configure
const config = createQueueConfig({
  provider: 'kafka',
  kafka: {
    brokers: ['localhost:9092'],
    clientId: 'my-service',
  },
});

// 2. Create provider
const provider = new KafkaProvider(config);
await provider.connect();

// 3. Produce
const producer = await provider.createProducer();
await producer.produce('orders.order.created', {
  key: 'order-123',
  payload: { orderId: 'order-123', amount: 99.99 },
});

// 4. Consume
const dlqProducer = await provider.createProducer();
const consumer = await provider.createConsumer({
  groupId: 'my-service-orders',
  topics: ['orders.order.created'],
  retryPolicy: new ExponentialBackoffRetry(3),
  dlqHandler: new KafkaDLQHandler(dlqProducer),
  handler: async (message, context) => {
    console.log(message.payload);
    await context.commit();
  },
});

await consumer.start();

Environment Variable Configuration

KAFKA_BROKERS=localhost:9092,localhost:9093
KAFKA_CLIENT_ID=my-service
KAFKA_SSL=false
QUEUE_SERVICE_NAME=my-service
QUEUE_LOG_LEVEL=info
import { KafkaProvider, loadConfigFromEnv } from '@module-queue/core';

const config = loadConfigFromEnv();
const provider = new KafkaProvider(config);

Documentation

Supported Brokers

| Broker | Status | |-----------|-----------| | Kafka | ✅ v1 | | RabbitMQ | 🗓 Planned | | AWS SQS | 🗓 Planned |

Development

# Install dependencies
npm install

# Run tests (unit)
npm test

# Run tests with coverage
npm run test:coverage

# Build the package
npm run build

# Lint
npm run lint

# Type check
npm run type-check

Integration tests (requires Docker)

docker-compose -f docker-compose.test.yml up -d
INTEGRATION=true npx vitest run tests/integration
docker-compose -f docker-compose.test.yml down

Contributing

See CONTRIBUTING.md.

License

MIT — see LICENSE.