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

@@ -11,7 +11,6 @@ import type { Protest } from '../../domain/entities/Protest';
import type { Driver } from '../../domain/entities/Driver';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { UseCaseOutputPort } from '@core/shared/application';
export interface GetRaceProtestsInput {
raceId: string;
@@ -28,12 +27,11 @@ export class GetRaceProtestsUseCase {
constructor(
private readonly protestRepository: IProtestRepository,
private readonly driverRepository: IDriverRepository,
private readonly output: UseCaseOutputPort<GetRaceProtestsResult>,
) {}
async execute(
input: GetRaceProtestsInput,
): Promise<Result<void, ApplicationErrorCode<GetRaceProtestsErrorCode, { message: string }>>> {
): Promise<Result<GetRaceProtestsResult, ApplicationErrorCode<GetRaceProtestsErrorCode, { message: string }>>> {
try {
const protests = await this.protestRepository.findByRaceId(input.raceId);
@@ -57,9 +55,7 @@ export class GetRaceProtestsUseCase {
drivers: validDrivers,
};
this.output.present(result);
return Result.ok(undefined);
return Result.ok(result);
} catch (error: unknown) {
const message =
error instanceof Error && error.message