nestjs/cqrs
56.1
Adequate · 8 November 2026
2.2k
lines of production code
TypeScript
primary language
7
measurements over time
What this system is
Features
Add ofType operator for filtering events by instance type
A new \ofType\ operator has been added to the \src/operators\ module, allowing users to filter event streams based on their runtime class type using \instanceof\. This operator accepts one or more type arguments (implementing \IEvent\) and returns a stream that only emits events matching those types, with TypeScript correctly inferring the narrowed union type for the emitted events.
src/operators · high confidence
Aggregate roots can now publish events with a dispatcher context
The new AggregateRootStorage component enables aggregate roots to publish events and event batches while passing an optional dispatcher context to the EventBus. This allows downstream event handlers to access the context of the operation that triggered the events, supporting more granular tracking or routing of event processing.
src/storages · high confidence
Initialize Husky commit and pre-commit hooks
The project now includes Husky configuration files to enforce code quality standards during development. A new pre-commit hook runs \lint-staged\ to lint staged files before each commit, and a commit-msg hook runs \commitlint\ to validate commit message format. These changes ensure consistent linting and commit message conventions are applied automatically.
.husky · high confidence
Introduction of async context propagation and strongly typed command/query handlers
This change introduces a new \AsyncContext\ mechanism in \src/scopes\ that attaches and merges context identifiers to command, query, or event objects, enabling asynchronous operations to maintain context across boundaries. Simultaneously, \src/classes\ now provides strongly typed \Command\ and \Query\ base classes with utility types (\CommandResult\, \QueryResult\) that extract result types, replacing previous untyped implementations. Users benefit from improved type safety when handling command/query results and reliable context propagation for async operations.
src/scopes · high confidence
New CQRS decorators for commands, queries, events, and sagas
The \src/decorators\ module now provides a complete set of decorators (\@CommandHandler\, \@QueryHandler\, \@EventsHandler\, \@Saga\, and \@Publishable\) to define CQRS components. These decorators register handlers by storing metadata on the target classes and their associated command/query/event types, using \crypto.randomUUID()\ to generate unique identifiers for each type. The \@EventsHandler\ decorator supports multiple event types and optional injectable options, while \@Saga\ marks properties as saga handlers. The \@Publishable\ decorator merges event publishing capabilities into the decorated class by registering it in the \AggregateRootStorage\.
src/decorators · high confidence
New default pub/sub implementations for commands, queries, and unhandled exceptions
The src/helpers directory now includes new default implementations for publishing commands (DefaultCommandPubSub), queries (DefaultQueryPubSub), and unhandled exceptions (DefaultUnhandledExceptionPubSub), alongside the existing DefaultPubSub for events and DefaultEventIdProvider. These helpers provide concrete, RxJS Subject-based publishers that implement the respective interfaces (ICommandPublisher, IQueryPublisher, IUnhandledExceptionPublisher), enabling users to handle these specific message types with consistent, out-of-the-box behavior without needing to write custom publisher logic.
src/helpers · high confidence
New query bus and handler interfaces for CQRS
The \src/interfaces/queries\ module now exposes a set of new TypeScript interfaces that define the contract for the Command Query Responsibility Segregation (CQRS) query layer. Specifically, \IQueryBus\ defines the execution methods for querying data, \IQueryHandler\ specifies the structure for handling queries with generic result types, \IQueryPublisher\ outlines the publishing contract, and supporting interfaces (\IQuery\, \IQueryResult\, \QueryMetadata\) establish the base types. These changes provide the foundational API definitions required for the new async context and strongly typed handler support introduced in the 6.0.0 release.
src/interfaces/queries · high confidence
Behavioural changes
Aggregate root commit behavior now clears events immediately upon publishing
The \commit\ method in the \WithAggregateRoot\ mixin now clears the internal event queue immediately after calling \publishAll\, rather than waiting for the publisher to settle. This ensures that callers who do not await the commit operation do not inadvertently publish the same events twice, while still providing a copy of the events to the dispatcher when a context is supplied so that awaiting callers can read them after the method returns.
src/mixins · high confidence
Command bus and handlers now support typed results and async context
The command bus interface now exposes overloaded execute methods that accept an optional AsyncContext and return a typed Promise\<R\>, allowing command handlers to specify their return types explicitly. Command handlers have been refactored from a callback-based signature to a Promise-based one, with generic type parameters that infer the result type from the command class. Additionally, new interfaces for command metadata and command publishing have been introduced to support these capabilities.
src/interfaces/commands · high confidence
Event bus interfaces expanded to support context and batch publishing
The event bus interfaces in \src/interfaces/events\ have been significantly expanded to support more granular control over event publishing. The \IEventBus\ interface now accepts optional \dispatcherContext\ and \asyncContext\ parameters for both single (\publish\) and batch (\publishAll\) operations, allowing handlers to access specific execution contexts. Additionally, new interfaces \EventIdProvider\ and \MessageSource\ have been introduced to support custom event ID strategies and event bridging, while \IEventPublisher\ and \IEventHandler\ have been updated with improved generics and documentation to reflect these capabilities.
src/interfaces/events · high confidence
Expanded CQRS interfaces and module configuration options
The library introduces new interfaces to support more granular CQRS patterns and dynamic module configuration. Users can now configure the CqrsModule via async options (useFactory, useClass, useValue, useExisting) and override specific publishers for commands, events, queries, and unhandled exceptions, as well as the event ID provider. New interfaces include IAggregateRoot for event-sourced aggregates with dispatcher context support, ISaga for typed saga definitions, and publishers for queries and unhandled exceptions. The legacy EventObservable interface has been removed, and the public API exports have been updated to include these new types.
src/interfaces · high confidence
Major CQRS rewrite: async context, publisher injection, and new QueryBus
The CQRS module has been rewritten to support NestJS v2+ and ESM, introducing a new QueryBus alongside the existing CommandBus and EventBus. A key behavioral change is the introduction of an AsyncContext that is now passed through command and event handlers, allowing scoped dependencies to be resolved correctly. The module now supports dynamic configuration via forRootAsync with useValue, useFactory, useClass, and useExisting options. Event publishing is now handled via injectable publishers (IEventPublisher, ICommandPublisher, IQueryPublisher) rather than direct subject emissions, and AggregateRoots can now commit with a dispatcher context. Additionally, an UnhandledExceptionBus has been added to capture and publish exceptions from commands and events.
src · high confidence
ObservableBus refactored to use RxJS 6+ and exposes subject via getter
The ObservableBus utility has been updated to align with RxJS 6+ module structure, replacing deprecated import paths (e.g., 'rxjs/Subject') with the unified 'rxjs' entry point and removing the custom 'ofType' operator in favor of standard RxJS filtering. Additionally, the internal subject is now stored in a private field (\_subject$) and exposed to consumers via a public getter, allowing direct access to the underlying subject stream while maintaining encapsulation.
src/utils · high confidence
Project infrastructure overhaul and ESM migration
The repository has been restructured to support modern development workflows and module standards. TypeScript configuration has been updated to use the 'nodenext' module resolution and ES2021 target, facilitating an ESM migration, while the build output directory is now explicitly ignored from version control. The testing framework has shifted to Vitest, evidenced by new configuration files for unit and end-to-end tests, and linting/formatter tools have been standardized with Prettier and Commitlint. Additionally, the project documentation has been refreshed to reflect the official NestJS branding, and an MIT license file has been added to clarify usage rights.
(repo-wide) · high confidence
Refined exception messages and expanded exception coverage
The exception classes in the CQRS module have been updated to provide more specific, actionable error messages to users. The CommandHandlerNotFoundException and QueryHandlerNotFoundException now include the specific command or query name that was not found, rather than a generic message. Additionally, new exception classes have been introduced for invalid command, event, and query handlers, as well as for unsupported saga scopes, ensuring that users receive clear guidance on how to correctly annotate their handlers or configure their sagas. The InvalidSagaException message was also clarified to specify that sagas should return an Observable stream.
src/exceptions · high confidence
Test coverage
Added end-to-end tests for CQRS module features; Expanded test suite for CQRS patterns and async context.
Dependencies
Routine dependency updates across development tooling
This release updates a wide range of development dependencies, including the NestJS framework, TypeScript, ESLint, Prettier, Jest, and various type definitions. These changes keep the project's tooling and build environment current with upstream releases.
(dependencies) · high confidence
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 57 → 56 (-0.7)
- Rubric changed (rubric-2026.10.5 → rubric-2026.11.2) — scores are not directly comparable.
Lenses
- Code Health 91 → 92 (+1.0)
- Architecture 85 → 85 (-0.6)
- Maturity 52 → 55 (+3.7)
- Readiness 58 → 62 (+3.6)
- Security 70 → 53 (-17.1)
- Domain Modelling 51 → 51 (+0.0)
- Performance 100 → 100 (+0.0)
New (2)
- Medium CVE: [GHSA redacted] (package-lock.json)
- Scattered collaborators
Changes since last survey
- 19 commits — 17 feature/other, 2 fixes
By area
- (root) — 15 commits
- .circleci/config.yml — 1 commit
- .github/release.yml — 1 commit
- src/event-bus.ts — 1 commit
- src/scopes — 1 commit
Notable commits
- fix: fix(async-context): let merge() accept async context as source (#2395)
- fix: fix(event-bus): provide async context as request to scoped handlers (#2393)
- change: chore(): release v12.1.1
- change: chore(): release v12.1.2
- change: chore(deps): update dependency @types/node to v26 (#2398)
- change: chore(deps): update dependency oxlint to v1.90.0 (#2396)
- change: chore(deps): update dependency oxlint to v1.91.0 (#2403)
- change: chore(deps): update dependency oxlint to v1.92.0 (#2407)
- change: chore(deps): update dependency release-it to v21.1.2 (#2402)
- change: chore(deps): update dependency vite to v8.3.6 (#2405)
- change: chore(deps): update dependency vitest to v4.1.12 (#2388)
- change: chore(deps): update nest monorepo to v12.2.0 (#2381)
- change: chore(deps): update nest monorepo to v12.3.2 (#2397)
- change: chore(deps): update nest monorepo to v12.3.3 (#2404)
- change: chore(deps): update nest monorepo to v12.4.0 (#2408)
- change: chore(deps): update node.js to v24.22.1 (#2394)
- change: chore: describe the package on npm (#2406)
- change: chore: exclude bots from generated release notes
- change: chore: ignore claude worktrees
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
nestjs/cqrs was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 8 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 00e9ed629f95fb956e8667c50b4bce03ec46d457 — the exact code this score is about.
- Scored under rubric-2026.11.2 — the same rubric and the same method as every other entry in this index.
- Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.3+preprod-45ab2cab63de.