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

@@ -2,7 +2,6 @@ import type { ILeagueRepository } from '../../domain/repositories/ILeagueReposit
import type { ISeasonRepository } from '../../domain/repositories/ISeasonRepository';
import type { ILeagueScoringConfigRepository } from '../../domain/repositories/ILeagueScoringConfigRepository';
import type { IGameRepository } from '../../domain/repositories/IGameRepository';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
@@ -28,17 +27,14 @@ export type GetLeagueFullConfigErrorCode = 'LEAGUE_NOT_FOUND' | 'REPOSITORY_ERRO
* Orchestrates domain logic and returns the configuration data.
*/
export class GetLeagueFullConfigUseCase {
constructor(
private readonly leagueRepository: ILeagueRepository,
constructor(private readonly leagueRepository: ILeagueRepository,
private readonly seasonRepository: ISeasonRepository,
private readonly leagueScoringConfigRepository: ILeagueScoringConfigRepository,
private readonly gameRepository: IGameRepository,
private readonly output: UseCaseOutputPort<GetLeagueFullConfigResult>,
) {}
private readonly gameRepository: IGameRepository) {}
async execute(
input: GetLeagueFullConfigInput,
): Promise<Result<void, ApplicationErrorCode<GetLeagueFullConfigErrorCode, { message: string }>>> {
): Promise<Result<GetLeagueFullConfigResult, ApplicationErrorCode<GetLeagueFullConfigErrorCode, { message: string }>>> {
const { leagueId } = input;
try {
@@ -77,8 +73,7 @@ export class GetLeagueFullConfigUseCase {
config,
};
this.output.present(result);
return Result.ok(undefined);
return Result.ok(result);
} catch (error) {
const message =
error instanceof Error && error.message