NestJS CQRS module with support EventStore.org. It requires @nestjs/cqrs. This library uses @eventstore/db-client that uses gRPC as the communication protocol.
$ yarn add unike-event-store
This module aims to bridge the gap between NestJs and popular event store broker Event Store.
import { EventStoreModule } from 'unike-event-store';
@Module({
imports: [
CqrsModule,
EventStoreModule.register({
connectionOptions: {
endpoint: 'esdb://localhost:2113',
},
}),
]
})
export class AppModule {}
import { CqrsModule } from '@nestjs/cqrs';
import { Module } from '@nestjs/common';
import { BuyerCreatedEvent } from './events/impl/buyer-created.event';
import { BuyerUpdatedEvent } from './events/impl/buyer-updated.event';
import { EventStoreModule } from 'unike-event-store';
@Module({
imports: [
CqrsModule,
EventStoreModule.registerFeature({
featureStreamName: '$et-buyers',
subscriptions: [
{
type: EventStoreSubscriptionType.CatchUp,
stream: '$et-buyers',
resolveLinkTos: true,
},
],
eventHandlers: {
BuyerCreatedEvent: (data) => new BuyerCreatedEvent(data.buyerDto),
BuyerUpdatedEvent: (data) =>
new BuyerUpdatedEvent(data.buyerId, data.buyerDto),
},
}),
],