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

@@ -10,7 +10,6 @@ import type { Game } from '../../domain/entities/Game';
import type { LeagueScoringPreset } from '../../domain/types/LeagueScoringPreset';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
export type GetAllLeaguesWithCapacityAndScoringInput = {};
@@ -32,7 +31,6 @@ export type GetAllLeaguesWithCapacityAndScoringErrorCode = 'REPOSITORY_ERROR';
/**
* Use Case for retrieving all leagues with capacity and scoring information.
* Orchestrates domain logic and delegates presentation to an output port.
*/
export class GetAllLeaguesWithCapacityAndScoringUseCase {
constructor(
@@ -42,14 +40,13 @@ export class GetAllLeaguesWithCapacityAndScoringUseCase {
private readonly leagueScoringConfigRepository: ILeagueScoringConfigRepository,
private readonly gameRepository: IGameRepository,
private readonly presetProvider: { getPresetById(presetId: string): LeagueScoringPreset | undefined },
private readonly output: UseCaseOutputPort<GetAllLeaguesWithCapacityAndScoringResult>,
) {}
async execute(
_input: GetAllLeaguesWithCapacityAndScoringInput = {},
): Promise<
Result<
void,
GetAllLeaguesWithCapacityAndScoringResult,
ApplicationErrorCode<
GetAllLeaguesWithCapacityAndScoringErrorCode,
{ message: string }
@@ -111,9 +108,7 @@ export class GetAllLeaguesWithCapacityAndScoringUseCase {
});
}
await this.output.present({ leagues: enrichedLeagues });
return Result.ok(undefined);
return Result.ok({ leagues: enrichedLeagues });
} catch (error: unknown) {
const message =
error instanceof Error && error.message