@nestjs/event-emitter

Event-driven architecture for NestJS, built on EventEmitter2

Library
npm
v3.1.0
251stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
81/100Excellent
Development Activity100
Maintenance84
Community60
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
77/100Good
Architecture80
Code Quality78
Innovation68
Learning Curve82

@nestjs/event-emitter wires the battle-tested eventemitter2 library into the Nest dependency-injection system, giving Nest applications a first-class in-process event bus. Instead of manually wiring listeners, providers declare @OnEvent() handlers that are automatically discovered and registered at bootstrap via Nest’s DiscoveryModule, letting different parts of an application communicate through fire-and-forget or awaited events rather than direct service-to-service calls.

This decoupling is especially useful for side effects that shouldn’t block a primary request path — sending a welcome email after signup, invalidating a cache after an update, or triggering a background job after a domain event — while still keeping everything inside a single process and fully typed.

What You Get

  • A global, injectable EventEmitter2 instance shared across the whole Nest application
  • @OnEvent() method decorator for declaring listeners anywhere in the DI graph, including request-scoped providers
  • Automatic listener discovery at bootstrap via Nest’s DiscoveryModule, no manual registration needed
  • Support for wildcard event names, async/awaited listeners, and listener priority/ordering options inherited from eventemitter2
  • EventEmitterReadinessWatcher to ensure listeners are fully wired before events are emitted during startup

Common Use Cases

  • Firing a user.created event after signup and having separate providers send a welcome email and provision default resources
  • Decoupling domain logic from side effects like audit logging, cache invalidation, or webhook dispatch
  • Coordinating request-scoped or durable-request-scoped providers that need to react to events within the same request context
  • Building a lightweight in-process pub/sub layer before introducing an external message broker

Under The Hood

Architecture - The module is a thin Nest-native wrapper around eventemitter2: EventEmitterModule.forRoot() registers a DiscoveryModule import plus providers for EventSubscribersLoader, EventsMetadataAccessor, and EventEmitterReadinessWatcher, and provides a single EventEmitter2 instance via a factory so it can be injected anywhere. At bootstrap, EventSubscribersLoader uses Nest’s DiscoveryService to walk every registered provider and controller, find methods carrying @OnEvent() metadata (read via EventsMetadataAccessor), and bind them onto the shared EventEmitter2 instance, including handling for request-scoped and durable-request-scoped providers so listeners resolve the correct instance per request.

Tech Stack - Built in TypeScript on top of eventemitter2 (the only runtime dependency) and Nest’s own @nestjs/common/@nestjs/core as peer dependencies; internal tooling uses oxlint for linting, vitest for e2e tests, and release-it plus Husky/commitlint for a conventional-commit release flow, reflecting the same tooling conventions used across the core NestJS org repos.

Code Quality - The tests/e2e suite exercises the module end-to-end against a real Nest TestingModule (module-e2e.spec.ts, inherit-context-id.spec.ts), covering request-scoped and durable-request-scoped consumer patterns, aliased providers, and custom decorators rather than just unit-testing the emitter in isolation. Source files are small and single-purpose (loader, accessor, watcher, module each in their own file), consistent with Nest’s own module conventions, though there is no explicit runtime validation of event payload shapes beyond what TypeScript enforces at compile time.

API Design - The public surface is intentionally minimal: one module import, one decorator (@OnEvent), and the underlying EventEmitter2 API for emitting. This keeps boilerplate low for consumers already familiar with Nest’s decorator-and-DI conventions, at the cost of relying on string event names with no first-class type-safe event map out of the box.

Used by 11 apps in this directory

TypeScript
72%
AGPL 3.0

APITable

Low Code Platforms · Databases

15,526

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
53
Repo Health
77
Technical
60
Dependency
Built with
TypeScript72%
Java22%
Updated 9 months ago
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,846

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript97%
Updated yesterday
TypeScript
95%
AGPL 3.0

Docmost

Productivity · Note Taking · Collaboration

21,411

Self-hosted collaborative wiki and knowledge base with real-time editing, diagrams, AI assistance, and enterprise access controls — a modern alternative to Confluence and Notion.

View details
89
Repo Health
70
Technical
71
Dependency
Built with
TypeScript95%
Updated yesterday
TypeScript
74%
AGPL 3.0

Ghostfolio

Invoicing Finance

9,153

Track your stocks, ETFs, and crypto with a privacy-first, self-hostable wealth management platform built for data-driven investors.

View details
93
Repo Health
79
Technical
71
Dependency
Built with
TypeScript74%
HTML23%
Updated yesterday
TypeScript
98%
Other

Hexabot

AI Development · Automation

1,186

Build and run agentic workflows across channels with YAML, tools, and RAG

View details
79
Repo Health
76
Technical
70
Dependency
Built with
TypeScript98%
Updated yesterday
TypeScript
64%
Other

NocoDB

No Code Platforms · Databases · Low Code Platforms

64,586

Turn any SQL database into a collaborative no-code spreadsheet with automatic REST APIs and real-time views.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript64%
Vue31%
Updated today
TypeScript
96%
Apache 2.0

Pezzo

AI Development · Monitoring

3,265

Open-source LLMOps platform for prompt management, AI observability, intelligent caching, and real-time cost tracking across LLM providers.

View details
59
Repo Health
75
Technical
67
Dependency
Built with
TypeScript96%
Updated 3 weeks ago
TypeScript
96%
Other

Refly

No Code Platforms · AI Development · Automation

7,490

Build deterministic, versioned agent skills from natural language—run them anywhere from Claude Code to Slack.

View details
66
Repo Health
76
Technical
64
Dependency
Built with
TypeScript96%
Updated 3 weeks ago
TypeScript
99%
Other

Teable

Databases · No Code Platforms

21,665

A no-code PostgreSQL database with spreadsheet UX, real-time collaboration, and native AI agents — built for teams that outgrow Airtable.

View details
79
Repo Health
76
Technical
64
Dependency
Built with
TypeScript99%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search