refactor driver module (wip)

This commit is contained in:
2025-12-22 10:24:40 +01:00
parent e7dbec4a85
commit 9da528d5bd
108 changed files with 842 additions and 947 deletions

View File

@@ -1,36 +1,17 @@
import type { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { CreateTeamErrorCode, CreateTeamResult } from '@core/racing/application/use-cases/CreateTeamUseCase';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
import type { CreateTeamResult } from '@core/racing/application/use-cases/CreateTeamUseCase';
import type { CreateTeamOutputDTO } from '../dtos/CreateTeamOutputDTO';
export type CreateTeamError = ApplicationErrorCode<CreateTeamErrorCode, { message: string }>;
export class CreateTeamPresenter {
export class CreateTeamPresenter implements UseCaseOutputPort<CreateTeamResult> {
private model: CreateTeamOutputDTO | null = null;
reset(): void {
this.model = null;
}
present(result: Result<CreateTeamResult, CreateTeamError>): void {
if (result.isErr()) {
const error = result.unwrapErr();
// Validation and expected domain errors map to an unsuccessful DTO
if (error.code === 'VALIDATION_ERROR' || error.code === 'LEAGUE_NOT_FOUND') {
this.model = {
id: '',
success: false,
};
return;
}
throw new Error(error.details?.message ?? 'Failed to create team');
}
const output = result.unwrap();
present(result: CreateTeamResult): void {
this.model = {
id: output.team.id,
id: result.team.id,
success: true,
};
}