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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@nivinjoseph/n-eda

v6.0.5

Published

Event Driven Architecture framework

Readme

n-eda

Event Driven Architecture framework for Node.js applications

Overview

n-eda is a powerful Event Driven Architecture framework that provides a robust infrastructure for building event-driven applications in Node.js. It supports various event handling patterns, distributed systems, and integration with different messaging systems.

Features

  • Event-driven architecture implementation
  • Support for multiple event handling patterns
  • Distributed event handling
  • Integration with Redis for event distribution
  • AWS Lambda integration
  • gRPC and RPC support
  • Topic-based event routing
  • Partitioned event processing
  • Observer pattern implementation
  • Dependency injection support
  • OpenTelemetry integration for observability

Installation

npm install @nivinjoseph/n-eda
# or
yarn add @nivinjoseph/n-eda

Requirements

  • Node.js >= 20.10
  • Redis (for distributed event handling)

Quick Start

import { EdaManager, Topic, Duration } from "@nivinjoseph/n-eda";

// Create an EDA manager instance
const edaManager = new EdaManager();

// Define topics with retention period and partition count
const userTopic = new Topic("user", Duration.fromMinutes(180), 10);
const orderTopic = new Topic("order", Duration.fromMinutes(180), 10);

// Register a custom EventBus implementation
edaManager.registerEventBus(RedisEventBus);

// Register topics
edaManager.registerTopics(userTopic, orderTopic);

// Register event handlers
@event(UserCreatedEvent)
class UserCreatedEventHandler extends EdaEventHandler<UserCreatedEvent> {
    public async handle(event: UserCreatedEvent): Promise<void> {
        // Handle the event
    }
}

edaManager.registerEventHandlers(UserCreatedEventHandler);

// Bootstrap the system
edaManager.bootstrap();

// Start consuming events
await edaManager.beginConsumption();

Core Concepts

EventBus

The EventBus is a crucial component of the EDA system that serves as the central hub for event publishing and distribution. It's responsible for:

  • Publishing events to the appropriate topics
  • Ensuring reliable event delivery
  • Managing event routing
  • Supporting distributed event processing

To use the EventBus:

// Publish an event
await eventBus.publish("UserTopic", new UserCreatedEvent(userData));

The EventBus must be registered with the EdaManager before it can be used:

// Register a custom EventBus implementation
edaManager.registerEventBus(RedisEventBus);

// Or use the default in-memory implementation
edaManager.registerEventBus(InMemoryEventBus);

Topics

Topics are the primary routing mechanism for events. They help organize and route events to appropriate handlers.

// Create a topic with retention period and partition count
const topic = new Topic("user", Duration.fromMinutes(180), 10);

Event Handlers

Event handlers process specific types of events. They can be registered with the EDA manager.

@event(UserCreatedEvent)
class UserCreatedEventHandler extends EdaEventHandler<UserCreatedEvent> {
    public async handle(event: UserCreatedEvent): Promise<void> {
        // Handle the event
    }
}

Distributed Processing

n-eda supports distributed event processing through Redis:

edaManager.registerEventSubscriptionManager(RedisEventSubMgr, "consumer-group-id");

AWS Lambda Integration

You can proxy events to AWS Lambda functions:

edaManager.proxyToAwsLambda({
    functionName: "my-lambda",
    region: "us-east-1"
});

gRPC and RPC Support

n-eda provides support for gRPC and RPC communication:

// gRPC
edaManager.proxyToGrpc({
    serviceUrl: "localhost:50051",
    protoPath: "./protos/service.proto"
});

// RPC
edaManager.proxyToRpc({
    serviceUrl: "http://localhost:3000"
});

Advanced Features

Partitioned Processing

You can implement custom partitioning logic for events:

edaManager.usePartitionKeyMapper((event) => event.userId);

Distributed Observer Pattern

Enable distributed observer pattern for cross-service communication:

edaManager.enableDistributedObserver(new Topic("system-events"));

Cleanup

Proper cleanup of resources:

await edaManager.dispose();

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support, please open an issue in the GitHub repository.