Skip to content

external eventbus module for @nestjs/cqrs

License

Notifications You must be signed in to change notification settings

goznauk/nest-external-eventbus

Repository files navigation

Nest Logo

A Cqrs External EventBus module for Nest framework (node.js)

Now available: Redis-EventBus

NPM Version Package License NPM Downloads

Installation

with npm

npm install --save nest-external-eventbus

with yarn

yarn add nest-external-eventbus

How to use?

RedisBusModule.forRoot(events, redisOption)

import { Module, Type } from '@nestjs/common';
import { HeroKilledDragonEvent, HeroFoundItemEvent } from './events'
import { RedisBusModule, RedisBusOptions } from 'nest-external-eventbus';

const events: Type[] = [HeroKilledDragonEvent, HeroFoundItemEvent];
const redisOption: RedisBusOptions = {
	subUrl: 'redis://localhost:6379',
	subChannel: 'REDIS_CHANNEL_HERE',
};

@Module({
	imports: [
		RedisBusModule.forRoot(events, redisOption),
	],
	controllers: [],
})
export class AppModule {}

Event Should extend StandardEvent

import { StandardEvent } from 'nest-external-eventbus';

export class HeroKilledDragonEvent extends StandardEvent {
	public constructor(public readonly payload: object) {
		super();
	}
}

Example

git clone git@github.com:goznauk/nest-external-eventbus.git
cd nest-external-eventbus
npm install

docker run -d  -p 6379:6379 -p 8001:8001 redis/redis-stack:latest

cd examples/simpleCqrs/
npm run start

pip3 install redis asyncio
python3 test.py

License

MIT

About

external eventbus module for @nestjs/cqrs

Resources

License

Stars

Watchers

Forks