This commit is contained in:
2025-12-21 22:35:38 +01:00
parent 3c64f328e2
commit 9bd2e630e6
38 changed files with 736 additions and 684 deletions

View File

@@ -18,13 +18,18 @@ export interface GetAllRacesResult {
export type GetAllRacesErrorCode = 'REPOSITORY_ERROR';
export class GetAllRacesUseCase {
private output: UseCaseOutputPort<GetAllRacesResult> | null = null;
constructor(
private readonly raceRepository: IRaceRepository,
private readonly leagueRepository: ILeagueRepository,
private readonly logger: Logger,
private readonly output: UseCaseOutputPort<GetAllRacesResult>,
) {}
setOutput(output: UseCaseOutputPort<GetAllRacesResult>) {
this.output = output;
}
async execute(
_input: GetAllRacesInput,
): Promise<Result<void, ApplicationErrorCode<GetAllRacesErrorCode, { message: string }>>> {
@@ -40,6 +45,9 @@ export class GetAllRacesUseCase {
};
this.logger.debug('Successfully retrieved all races.');
if (!this.output) {
throw new Error('Output not set');
}
this.output.present(result);
return Result.ok(undefined);
} catch (error) {