File tree 3 files changed +21
-1
lines changed
3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { CommandHandler , ICommandHandler } from '@nestjs/cqrs' ;
2
+ import { CreateRegisterCouponCommand } from '../command' ;
3
+ import { Logger } from '@nestjs/common' ;
4
+
5
+ @CommandHandler ( CreateRegisterCouponCommand )
6
+ export class CouponRegisterEventHandler
7
+ implements ICommandHandler < CreateRegisterCouponCommand >
8
+ {
9
+ public constructor ( private readonly logger : Logger ) { }
10
+
11
+ public async execute ( command : CreateRegisterCouponCommand ) : Promise < void > {
12
+ this . logger . verbose (
13
+ `Register coupon ${ command . id } for user ${ command . userId } ` ,
14
+ ) ;
15
+ }
16
+ }
Original file line number Diff line number Diff line change 1
1
export * from './user.handler' ;
2
2
export * from './user.created.event-handler' ;
3
+ export * from './coupon.register.event-handler' ;
Original file line number Diff line number Diff line change @@ -4,7 +4,8 @@ import { UserRepository } from './repository';
4
4
import { UserHandler } from './handler/user.handler' ;
5
5
import { UserController } from './controller/user.controller' ;
6
6
import { CqrsModule } from '@nestjs/cqrs' ;
7
- import { UserCreatedEventHandler } from './handler' ;
7
+ import { CouponRegisterEventHandler , UserCreatedEventHandler } from './handler' ;
8
+ import { UserSaga } from './saga' ;
8
9
9
10
@Module ( {
10
11
imports : [ CqrsModule ] ,
@@ -13,7 +14,9 @@ import { UserCreatedEventHandler } from './handler';
13
14
UserRepository ,
14
15
UserHandler ,
15
16
UserCreatedEventHandler ,
17
+ CouponRegisterEventHandler ,
16
18
UserService ,
19
+ UserSaga ,
17
20
] ,
18
21
controllers : [ UserController ] ,
19
22
} )
You can’t perform that action at this time.
0 commit comments