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';
@@ -30,12 +29,11 @@ export class GetLeagueRosterJoinRequestsUseCase {
private readonly leagueMembershipRepository: ILeagueMembershipRepository,
private readonly driverRepository: IDriverRepository,
private readonly leagueRepository: ILeagueRepository,
private readonly output: UseCaseOutputPort<GetLeagueRosterJoinRequestsResult>,
) {}
async execute(
input: GetLeagueRosterJoinRequestsInput,
): Promise<Result<void, ApplicationErrorCode<GetLeagueRosterJoinRequestsErrorCode, { message: string }>>> {
): Promise<Result<GetLeagueRosterJoinRequestsResult, ApplicationErrorCode<GetLeagueRosterJoinRequestsErrorCode, { message: string }>>> {
try {
const leagueExists = await this.leagueRepository.exists(input.leagueId);
@@ -65,9 +63,7 @@ export class GetLeagueRosterJoinRequestsUseCase {
driver: driverMap.get(request.driverId.toString())!,
}));
this.output.present({ joinRequests: enrichedJoinRequests });
return Result.ok(undefined);
return Result.ok({ joinRequests: enrichedJoinRequests });
} catch (error: unknown) {
const message = error instanceof Error ? error.message : 'Failed to load league roster join requests';