0.0.5 • Published 2 years ago

nest-external-eventbus v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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