refactor use cases
This commit is contained in:
@@ -9,7 +9,7 @@ import type { AuthenticatedUser } from '../ports/IdentityProviderPort';
|
||||
import type { IdentitySessionPort } from '../ports/IdentitySessionPort';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
import type { UseCaseOutputPort, Logger } from '@core/shared/application';
|
||||
import type { Logger } from '@core/shared/application';
|
||||
|
||||
export type SignupWithEmailInput = {
|
||||
email: string;
|
||||
@@ -43,11 +43,10 @@ export class SignupWithEmailUseCase {
|
||||
private readonly userRepository: IUserRepository,
|
||||
private readonly sessionPort: IdentitySessionPort,
|
||||
private readonly logger: Logger,
|
||||
private readonly output: UseCaseOutputPort<SignupWithEmailResult>,
|
||||
) {}
|
||||
|
||||
async execute(input: SignupWithEmailInput): Promise<
|
||||
Result<void, SignupWithEmailApplicationError>
|
||||
Result<SignupWithEmailResult, SignupWithEmailApplicationError>
|
||||
> {
|
||||
// Validate email format
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
@@ -119,9 +118,7 @@ export class SignupWithEmailUseCase {
|
||||
isNewUser: true,
|
||||
};
|
||||
|
||||
this.output.present(result);
|
||||
|
||||
return Result.ok(undefined);
|
||||
return Result.ok(result);
|
||||
} catch (error) {
|
||||
const message =
|
||||
error instanceof Error && error.message
|
||||
|
||||
Reference in New Issue
Block a user