From 2edb8c5eefb298cc070c0b0296d74a4218dc12f0 Mon Sep 17 00:00:00 2001 From: alexeh Date: Fri, 18 Oct 2024 06:28:55 +0200 Subject: [PATCH] refactor event handling --- api/src/modules/admin/admin.module.ts | 3 --- api/src/modules/auth/auth.module.ts | 11 +++++++++-- ...s => request-password-recovery-command.handler.ts} | 4 ++-- .../handlers/password-recovery-requested.handler.ts | 0 .../events/password-recovery-requested.event.ts | 0 5 files changed, 11 insertions(+), 7 deletions(-) rename api/src/modules/auth/commands/{request-password-recovery.handler.ts => request-password-recovery-command.handler.ts} (87%) rename api/src/modules/{admin => auth}/events/handlers/password-recovery-requested.handler.ts (100%) rename api/src/modules/{admin => auth}/events/password-recovery-requested.event.ts (100%) diff --git a/api/src/modules/admin/admin.module.ts b/api/src/modules/admin/admin.module.ts index 81388143..b38ca3c5 100644 --- a/api/src/modules/admin/admin.module.ts +++ b/api/src/modules/admin/admin.module.ts @@ -2,12 +2,9 @@ import { Module } from '@nestjs/common'; import { AdminController } from './admin.controller'; import { AuthModule } from '@api/modules/auth/auth.module'; import { ImportModule } from '@api/modules/import/import.module'; -import { NewUserEventHandler } from '@api/modules/admin/events/handlers/new-user-event.handler'; -import { PasswordRecoveryRequestedEventHandler } from '@api/modules/admin/events/handlers/password-recovery-requested.handler'; @Module({ imports: [AuthModule, ImportModule], - providers: [NewUserEventHandler, PasswordRecoveryRequestedEventHandler], controllers: [AdminController], }) export class AdminModule {} diff --git a/api/src/modules/auth/auth.module.ts b/api/src/modules/auth/auth.module.ts index 840e7eff..7d6b559b 100644 --- a/api/src/modules/auth/auth.module.ts +++ b/api/src/modules/auth/auth.module.ts @@ -3,12 +3,19 @@ import { AuthMailer } from '@api/modules/auth/services/auth.mailer'; import { NotificationsModule } from '@api/modules/notifications/notifications.module'; import { AuthenticationController } from '@api/modules/auth/authentication.controller'; import { AuthenticationModule } from '@api/modules/auth/authentication.module'; -import { RequestPasswordRecoveryHandler } from '@api/modules/auth/commands/request-password-recovery.handler'; +import { RequestPasswordRecoveryCommandHandler } from '@api/modules/auth/commands/request-password-recovery-command.handler'; +import { NewUserEventHandler } from '@api/modules/admin/events/handlers/new-user-event.handler'; +import { PasswordRecoveryRequestedEventHandler } from '@api/modules/auth/events/handlers/password-recovery-requested.handler'; @Module({ imports: [AuthenticationModule, NotificationsModule], controllers: [AuthenticationController], - providers: [AuthMailer, RequestPasswordRecoveryHandler], + providers: [ + AuthMailer, + RequestPasswordRecoveryCommandHandler, + NewUserEventHandler, + PasswordRecoveryRequestedEventHandler, + ], exports: [AuthenticationModule, AuthMailer], }) export class AuthModule {} diff --git a/api/src/modules/auth/commands/request-password-recovery.handler.ts b/api/src/modules/auth/commands/request-password-recovery-command.handler.ts similarity index 87% rename from api/src/modules/auth/commands/request-password-recovery.handler.ts rename to api/src/modules/auth/commands/request-password-recovery-command.handler.ts index cd797b8d..36797681 100644 --- a/api/src/modules/auth/commands/request-password-recovery.handler.ts +++ b/api/src/modules/auth/commands/request-password-recovery-command.handler.ts @@ -3,10 +3,10 @@ import { AuthMailer } from '@api/modules/auth/services/auth.mailer'; import { RequestPasswordRecoveryCommand } from '@api/modules/auth/commands/request-password-recovery.command'; import { UsersService } from '@api/modules/users/users.service'; import { NotFoundException } from '@nestjs/common'; -import { PasswordRecoveryRequestedEvent } from '@api/modules/admin/events/password-recovery-requested.event'; +import { PasswordRecoveryRequestedEvent } from '@api/modules/auth/events/password-recovery-requested.event'; @CommandHandler(RequestPasswordRecoveryCommand) -export class RequestPasswordRecoveryHandler +export class RequestPasswordRecoveryCommandHandler implements ICommandHandler { constructor( diff --git a/api/src/modules/admin/events/handlers/password-recovery-requested.handler.ts b/api/src/modules/auth/events/handlers/password-recovery-requested.handler.ts similarity index 100% rename from api/src/modules/admin/events/handlers/password-recovery-requested.handler.ts rename to api/src/modules/auth/events/handlers/password-recovery-requested.handler.ts diff --git a/api/src/modules/admin/events/password-recovery-requested.event.ts b/api/src/modules/auth/events/password-recovery-requested.event.ts similarity index 100% rename from api/src/modules/admin/events/password-recovery-requested.event.ts rename to api/src/modules/auth/events/password-recovery-requested.event.ts