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,6 +1,5 @@
import type { Logger } from '@core/shared/application';
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 { Race } from '../../domain/entities/Race';
import type { ILeagueRepository } from '../../domain/repositories/ILeagueRepository';
@@ -27,12 +26,11 @@ export class GetRacesPageDataUseCase {
private readonly raceRepository: IRaceRepository,
private readonly leagueRepository: ILeagueRepository,
private readonly logger: Logger,
private readonly output: UseCaseOutputPort<GetRacesPageDataResult>,
) {}
async execute(
input: GetRacesPageDataInput,
): Promise<Result<void, ApplicationErrorCode<GetRacesPageDataErrorCode, { message: string }>>> {
): Promise<Result<GetRacesPageDataResult, ApplicationErrorCode<GetRacesPageDataErrorCode, { message: string }>>> {
this.logger.debug('GetRacesPageDataUseCase:execute', { input });
try {
@@ -61,9 +59,7 @@ export class GetRacesPageDataUseCase {
races,
};
this.output.present(result);
return Result.ok(undefined);
return Result.ok(result);
} catch (error: unknown) {
const message =
error instanceof Error && error.message
@@ -81,4 +77,4 @@ export class GetRacesPageDataUseCase {
});
}
}
}
}