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,5 +1,4 @@
import { Result } from '@core/shared/application/Result';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { League } from '../../domain/entities/League';
import type { Race } from '../../domain/entities/Race';
@@ -40,12 +39,11 @@ export class GetRaceDetailUseCase {
private readonly raceRegistrationRepository: IRaceRegistrationRepository,
private readonly resultRepository: IResultRepository,
private readonly leagueMembershipRepository: ILeagueMembershipRepository,
private readonly output: UseCaseOutputPort<GetRaceDetailResult>,
) {}
async execute(
input: GetRaceDetailInput,
): Promise<Result<void, ApplicationErrorCode<GetRaceDetailErrorCode, { message: string }>>> {
): Promise<Result<GetRaceDetailResult, ApplicationErrorCode<GetRaceDetailErrorCode, { message: string }>>> {
const { raceId, driverId } = input;
try {
@@ -97,9 +95,7 @@ export class GetRaceDetailUseCase {
canRegister,
};
this.output.present(result);
return Result.ok(undefined);
return Result.ok(result);
} catch (error: unknown) {
const message =
error instanceof Error && error.message
@@ -112,4 +108,4 @@ export class GetRaceDetailUseCase {
});
}
}
}
}