refactor use cases

This commit is contained in:
2026-01-08 15:34:51 +01:00
parent d984ab24a8
commit 52e9a2f6a7
362 changed files with 5192 additions and 8409 deletions

View File

@@ -1,7 +1,7 @@
import type { IdentityProviderPort, AuthProvider, StartAuthCommand } from '../ports/IdentityProviderPort';
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 StartAuthInput = {
provider: AuthProvider;
@@ -21,10 +21,9 @@ export class StartAuthUseCase {
constructor(
private readonly provider: IdentityProviderPort,
private readonly logger: Logger,
private readonly output: UseCaseOutputPort<StartAuthResult>,
) {}
async execute(input: StartAuthInput): Promise<Result<void, StartAuthApplicationError>> {
async execute(input: StartAuthInput): Promise<Result<StartAuthResult, StartAuthApplicationError>> {
try {
const command: StartAuthCommand = input.returnTo
? {
@@ -38,9 +37,8 @@ export class StartAuthUseCase {
const { redirectUrl, state } = await this.provider.startAuth(command);
const result: StartAuthResult = { redirectUrl, state };
this.output.present(result);
return Result.ok(undefined);
return Result.ok(result);
} catch (error) {
const message =
error instanceof Error && error.message