feat: Event architecture implemented
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { AuthService } from './auth.service';
|
||||
import { AuthController } from './auth.controller';
|
||||
import { APP_GUARD, Reflector } from '@nestjs/core';
|
||||
import { APP_GUARD } from '@nestjs/core';
|
||||
import { AuthGuard } from './guards/auth.guard';
|
||||
import { UserModule } from 'src/user/user.module';
|
||||
import { JwtModule } from '@nestjs/jwt';
|
||||
import { RequestContextModule } from 'core/als/request-context.module';
|
||||
import { MailModule } from 'src/mail/mail.module';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
@@ -22,7 +21,6 @@ import { MailModule } from 'src/mail/mail.module';
|
||||
UserModule,
|
||||
JwtModule,
|
||||
RequestContextModule,
|
||||
MailModule
|
||||
],
|
||||
})
|
||||
export class AuthModule { }
|
||||
|
||||
@@ -5,8 +5,7 @@ import * as bcrypt from 'bcrypt';
|
||||
import { UserService } from 'src/user/user.service';
|
||||
import { TokenInputType } from './types';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import EmailTemplates from 'common/emails';
|
||||
import { MailService } from 'src/mail/mail.service';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
|
||||
@Injectable()
|
||||
@Public()
|
||||
@@ -14,7 +13,7 @@ export class AuthService {
|
||||
constructor(
|
||||
private readonly userService: UserService,
|
||||
private readonly jwtService: JwtService,
|
||||
private readonly mailService: MailService,
|
||||
private readonly eventEmitter: EventEmitter2
|
||||
) { }
|
||||
|
||||
async register(dto: RegisterUserRequestDTO) {
|
||||
@@ -24,11 +23,8 @@ export class AuthService {
|
||||
password: hashedPassword,
|
||||
});
|
||||
|
||||
this.mailService.sendMail({
|
||||
to: dto.email,
|
||||
subject: "Welcome onboard",
|
||||
body: EmailTemplates.welcomeToApp
|
||||
})
|
||||
this.eventEmitter.emit('user.sign_up', dto.email)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user