ocoda/event-sourcing
An event-sourcing library for NestJS
Report a bug | Request a feature
@ocoda/event-sourcing is a library for NestJS with the building blocks for Domain-Driven Design (DDD), CQRS and Event Sourcing:
Command<TResult> and Query<TResult> give execute() its result type.readAll() reads in order, for projections and consumers that resume from a checkpoint.[!NOTE] 4.0 is released: NestJS 12, ES modules only, Node.js 22.12 or later, global positions and
readAll(), typed buses and awaited publishers.
No download data available
No tracked packages depend on this.
Upgrading from 3.x? Follow the migration guide. 3.x is on the latest-3 tag and receives security and critical fixes until at least 2027-03-31.
| Line | npm tag | NestJS | Node.js | Module format | Support |
|---|---|---|---|---|---|
| 4.x | latest | 12 | 22.12 or later | ES modules only; CommonJS apps load them through require() | Supported |
| 3.x | latest-3 | 11 | 20 or later | CommonJS | Security and critical fixes until at least 2027-03-31 |
See versioning and support for the tested database versions and the support policy.
Install the core. It falls back to in-memory event and snapshot stores, which are fine for tests and prototypes:
npm install @ocoda/event-sourcing@4 # 4.x, NestJS 12
npm install @ocoda/event-sourcing@3 # 3.x, NestJS 11
For persistence, add an integration. On 4.x the database driver is a peer dependency, so install it next to the integration:
# PostgreSQL
npm install @ocoda/event-sourcing-postgres@4 pg pg-cursor
# MariaDB or MySQL
npm install @ocoda/event-sourcing-mariadb@4 mariadb
# MongoDB
npm install @ocoda/event-sourcing-mongodb@4 mongodb
Keep the core and the integrations on the same version. TypeScript projects need TypeScript 5.4 or later, and, with PostgreSQL, @types/pg and @types/pg-cursor.
On 3.x, install the integration with @3 and leave out the driver, which the integration brings along. The DynamoDB store (@ocoda/event-sourcing-dynamodb@3) is only available on 3.x.
docker compose.This library is inspired by @nestjs/cqrs