refactor dtos to ports

This commit is contained in:
2025-12-19 14:08:27 +01:00
parent 2ab86ec9bd
commit 499562c456
106 changed files with 386 additions and 1009 deletions

View File

@@ -16,6 +16,7 @@ import type { AsyncUseCase } from '@core/shared/application';
import type { Logger } from '@core/shared/application';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { CreateTeamOutputPort } from '../ports/output/CreateTeamOutputPort';
export interface CreateTeamCommandDTO {
name: string;
@@ -25,12 +26,8 @@ export interface CreateTeamCommandDTO {
leagues: string[];
}
export interface CreateTeamResultDTO {
team: Team;
}
export class CreateTeamUseCase
implements AsyncUseCase<CreateTeamCommandDTO, CreateTeamResultDTO, 'ALREADY_IN_TEAM' | 'REPOSITORY_ERROR'>
implements AsyncUseCase<CreateTeamCommandDTO, CreateTeamOutputPort, 'ALREADY_IN_TEAM' | 'REPOSITORY_ERROR'>
{
constructor(
private readonly teamRepository: ITeamRepository,
@@ -40,7 +37,7 @@ export class CreateTeamUseCase
async execute(
command: CreateTeamCommandDTO,
): Promise<Result<CreateTeamResultDTO, ApplicationErrorCode<'ALREADY_IN_TEAM' | 'REPOSITORY_ERROR', { message: string }>>> {
): Promise<Result<CreateTeamOutputPort, ApplicationErrorCode<'ALREADY_IN_TEAM' | 'REPOSITORY_ERROR', { message: string }>>> {
this.logger.debug('Executing CreateTeamUseCase', { command });
const { name, tag, description, ownerId, leagues } = command;
@@ -80,7 +77,7 @@ export class CreateTeamUseCase
await this.membershipRepository.saveMembership(membership);
this.logger.debug('Team membership created successfully.');
const result: CreateTeamResultDTO = { team: createdTeam };
const result: CreateTeamOutputPort = { team: createdTeam };
this.logger.debug('CreateTeamUseCase completed successfully.', { result });
return Result.ok(result);
} catch (error) {