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,4 +1,3 @@
import type { UseCaseOutputPort } from '@core/shared/application';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { Driver } from '../../domain/entities/Driver';
@@ -29,13 +28,12 @@ export class GetLeagueStandingsUseCase {
constructor(
private readonly standingRepository: IStandingRepository,
private readonly driverRepository: IDriverRepository,
private readonly output: UseCaseOutputPort<GetLeagueStandingsResult>,
) {}
async execute(
input: GetLeagueStandingsInput,
): Promise<
Result<void, ApplicationErrorCode<GetLeagueStandingsErrorCode, { message: string }>>
Result<GetLeagueStandingsResult, ApplicationErrorCode<GetLeagueStandingsErrorCode, { message: string }>>
> {
try {
const standings = await this.standingRepository.findByLeagueId(input.leagueId);
@@ -56,9 +54,7 @@ export class GetLeagueStandingsUseCase {
})),
};
this.output.present(result);
return Result.ok(undefined);
return Result.ok(result);
} catch (error) {
return Result.err({
code: 'REPOSITORY_ERROR',