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

@@ -4,7 +4,6 @@ import type { IDriverRepository } from '../../domain/repositories/IDriverReposit
import type { ILeagueRepository } from '../../domain/repositories/ILeagueRepository';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import { Result } from '@core/shared/application/Result';
import type { UseCaseOutputPort } from '@core/shared/application';
import type { Race } from '../../domain/entities/Race';
import type { Protest } from '../../domain/entities/Protest';
import type { Driver } from '../../domain/entities/Driver';
@@ -34,16 +33,11 @@ export class GetLeagueProtestsUseCase {
private readonly protestRepository: IProtestRepository,
private readonly driverRepository: IDriverRepository,
private readonly leagueRepository: ILeagueRepository,
private readonly output: UseCaseOutputPort<GetLeagueProtestsResult>,
) {}
get outputPort(): UseCaseOutputPort<GetLeagueProtestsResult> {
return this.output;
}
async execute(
input: GetLeagueProtestsInput,
): Promise<Result<void, ApplicationErrorCode<GetLeagueProtestsErrorCode, { message: string }>>> {
): Promise<Result<GetLeagueProtestsResult, ApplicationErrorCode<GetLeagueProtestsErrorCode, { message: string }>>> {
try {
const league = await this.leagueRepository.findById(input.leagueId);
@@ -89,9 +83,7 @@ export class GetLeagueProtestsUseCase {
protests: protestsWithEntities,
};
this.output.present(result);
return Result.ok(undefined);
return Result.ok(result);
} catch (error: unknown) {
const message =
error instanceof Error && error.message