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';
@@ -27,12 +26,11 @@ export class GetLeagueRosterMembersUseCase {
private readonly leagueMembershipRepository: ILeagueMembershipRepository,
private readonly driverRepository: IDriverRepository,
private readonly leagueRepository: ILeagueRepository,
private readonly output: UseCaseOutputPort<GetLeagueRosterMembersResult>,
) {}
async execute(
input: GetLeagueRosterMembersInput,
): Promise<Result<void, ApplicationErrorCode<GetLeagueRosterMembersErrorCode, { message: string }>>> {
): Promise<Result<GetLeagueRosterMembersResult, ApplicationErrorCode<GetLeagueRosterMembersErrorCode, { message: string }>>> {
try {
const leagueExists = await this.leagueRepository.exists(input.leagueId);
@@ -59,9 +57,7 @@ export class GetLeagueRosterMembersUseCase {
driver: driverMap.get(membership.driverId.toString())!,
}));
this.output.present({ members });
return Result.ok(undefined);
return Result.ok({ members });
} catch (error: unknown) {
const message = error instanceof Error ? error.message : 'Failed to load league roster members';