refactor use cases
This commit is contained in:
@@ -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';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user