This repository was archived by the owner on Aug 1, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +11
-5142
lines changed Expand file tree Collapse file tree 4 files changed +11
-5142
lines changed Original file line number Diff line number Diff line change
1
+ //Here we import all events
2
+ import '../subscribers/user' ;
Original file line number Diff line number Diff line change @@ -3,6 +3,9 @@ import dependencyInjectorLoader from './dependencyInjector';
3
3
import mongooseLoader from './mongoose' ;
4
4
import jobsLoader from './jobs' ;
5
5
import Logger from './logger' ;
6
+ //We have to import at least all the events once so they can be triggered
7
+ import './events' ;
8
+
6
9
export default async ( { expressApp } ) => {
7
10
const mongoConnection = await mongooseLoader ( ) ;
8
11
Logger . info ( '✌️ DB loaded and connected!' ) ;
Original file line number Diff line number Diff line change @@ -5,14 +5,18 @@ import config from '../config';
5
5
import * as argon2 from 'argon2' ;
6
6
import { randomBytes } from 'crypto' ;
7
7
import { IUser , IUserInputDTO } from '../interfaces/IUser' ;
8
+ import { EventDispatcher , EventDispatcherInterface } from '../decorators/eventDispatcher' ;
9
+ import events from '../subscribers/events' ;
8
10
9
11
@Service ( )
10
12
export default class AuthService {
11
13
constructor (
12
14
@Inject ( 'userModel' ) private userModel : Models . UserModel ,
13
15
private mailer : MailerService ,
14
16
@Inject ( 'logger' ) private logger ,
17
+ @EventDispatcher ( ) private eventDispatcher : EventDispatcherInterface ,
15
18
) { }
19
+ ) { }
16
20
17
21
public async SignUp ( userInputDTO : IUserInputDTO ) : Promise < { user : IUser ; token : string } > {
18
22
try {
@@ -51,6 +55,8 @@ export default class AuthService {
51
55
this . logger . silly ( 'Sending welcome email' ) ;
52
56
await this . mailer . SendWelcomeEmail ( userRecord ) ;
53
57
58
+ this . eventDispatcher . dispatch ( events . user . signUp , { user : userRecord } ) ;
59
+
54
60
/**
55
61
* @TODO This is not the best way to deal with this
56
62
* There should exist a 'Mapper' layer
You can’t perform that action at this time.
0 commit comments