24 lines
778 B
TypeScript
24 lines
778 B
TypeScript
import { ITransactionManager } from "@/core/common/infrastructure/database";
|
|
import { logger } from "@/core/logger";
|
|
import { Result } from "@repo/rdx-utils";
|
|
import { RegisterData } from "../../domain";
|
|
import { IAuthService } from "../../domain/services";
|
|
|
|
export class RegisterUseCase {
|
|
constructor(
|
|
private readonly authService: IAuthService,
|
|
private readonly transactionManager: ITransactionManager
|
|
) {}
|
|
|
|
public async execute(registerData: RegisterData) {
|
|
return await this.transactionManager.complete(async (transaction) => {
|
|
try {
|
|
return await this.authService.registerUser(registerData, transaction);
|
|
} catch (error: unknown) {
|
|
logger.error(error as Error);
|
|
return Result.fail(error as Error);
|
|
}
|
|
});
|
|
}
|
|
}
|