refactor core presenters
This commit is contained in:
@@ -4,7 +4,7 @@ import type { ILeagueScoringConfigRepository } from '../../domain/repositories/I
|
||||
import type { IGameRepository } from '../../domain/repositories/IGameRepository';
|
||||
import type { GetLeagueScoringPresetByIdInputPort } from '../ports/input/GetLeagueScoringPresetByIdInputPort';
|
||||
import type { LeagueScoringPresetOutputPort } from '../ports/output/LeagueScoringPresetOutputPort';
|
||||
import type { LeagueScoringConfigData } from '../presenters/ILeagueScoringConfigPresenter';
|
||||
import type { LeagueScoringConfigOutputPort } from '../ports/output/LeagueScoringConfigOutputPort';
|
||||
import type { AsyncUseCase } from '@core/shared/application/AsyncUseCase';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
@@ -20,7 +20,7 @@ type GetLeagueScoringConfigErrorCode =
|
||||
* Use Case for retrieving a league's scoring configuration for its active season.
|
||||
*/
|
||||
export class GetLeagueScoringConfigUseCase
|
||||
implements AsyncUseCase<{ leagueId: string }, LeagueScoringConfigData, GetLeagueScoringConfigErrorCode>
|
||||
implements AsyncUseCase<{ leagueId: string }, LeagueScoringConfigOutputPort, GetLeagueScoringConfigErrorCode>
|
||||
{
|
||||
constructor(
|
||||
private readonly leagueRepository: ILeagueRepository,
|
||||
@@ -30,7 +30,7 @@ export class GetLeagueScoringConfigUseCase
|
||||
private readonly getLeagueScoringPresetById: (input: GetLeagueScoringPresetByIdInputPort) => Promise<LeagueScoringPresetOutputPort | undefined>,
|
||||
) {}
|
||||
|
||||
async execute(params: { leagueId: string }): Promise<Result<LeagueScoringConfigData, ApplicationErrorCode<GetLeagueScoringConfigErrorCode>>> {
|
||||
async execute(params: { leagueId: string }): Promise<Result<LeagueScoringConfigOutputPort, ApplicationErrorCode<GetLeagueScoringConfigErrorCode>>> {
|
||||
const { leagueId } = params;
|
||||
|
||||
const league = await this.leagueRepository.findById(leagueId);
|
||||
@@ -64,7 +64,7 @@ export class GetLeagueScoringConfigUseCase
|
||||
const presetId = scoringConfig.scoringPresetId;
|
||||
const preset = presetId ? await this.getLeagueScoringPresetById({ presetId }) : undefined;
|
||||
|
||||
const data: LeagueScoringConfigData = {
|
||||
const output: LeagueScoringConfigOutputPort = {
|
||||
leagueId: league.id,
|
||||
seasonId: activeSeason.id,
|
||||
gameId: game.id,
|
||||
@@ -74,6 +74,6 @@ export class GetLeagueScoringConfigUseCase
|
||||
championships: scoringConfig.championships,
|
||||
};
|
||||
|
||||
return Result.ok(data);
|
||||
return Result.ok(output);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user