refactor driver module (wip)

This commit is contained in:
2025-12-22 01:43:34 +01:00
parent b445d6dd37
commit e7dbec4a85
31 changed files with 379 additions and 395 deletions

View File

@@ -92,7 +92,7 @@ export type GetProfileOverviewErrorCode =
| 'DRIVER_NOT_FOUND'
| 'REPOSITORY_ERROR';
export class GetProfileOverviewUseCase implements UseCase<GetProfileOverviewInput, void, GetProfileOverviewErrorCode> {
export class GetProfileOverviewUseCase implements UseCase<GetProfileOverviewInput, GetProfileOverviewResult, GetProfileOverviewErrorCode> {
constructor(
private readonly driverRepository: IDriverRepository,
private readonly teamRepository: ITeamRepository,
@@ -102,13 +102,12 @@ export class GetProfileOverviewUseCase implements UseCase<GetProfileOverviewInpu
private readonly driverExtendedProfileProvider: DriverExtendedProfileProvider,
private readonly getDriverStats: (driverId: string) => ProfileDriverStatsAdapter | null,
private readonly getAllDriverRankings: () => DriverRankingEntry[],
private readonly output: UseCaseOutputPort<GetProfileOverviewResult>,
) {}
async execute(
input: GetProfileOverviewInput,
): Promise<
Result<void, ApplicationErrorCode<GetProfileOverviewErrorCode, { message: string }>>
Result<GetProfileOverviewResult, ApplicationErrorCode<GetProfileOverviewErrorCode, { message: string }>>
> {
try {
const { driverId } = input;
@@ -144,9 +143,7 @@ export class GetProfileOverviewUseCase implements UseCase<GetProfileOverviewInpu
extendedProfile,
};
this.output.present(result);
return Result.ok(undefined);
return Result.ok(result);
} catch (error) {
return Result.err({
code: 'REPOSITORY_ERROR',