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 { IRaceRepository } from '../../domain/repositories/IRaceRepository'
import type { Logger } from '@core/shared/application';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
import type { Race } from '../../domain/entities/Race';
export type ReopenRaceInput = {
@@ -33,12 +32,11 @@ export class ReopenRaceUseCase {
constructor(
private readonly raceRepository: IRaceRepository,
private readonly logger: Logger,
private readonly output: UseCaseOutputPort<ReopenRaceResult>,
) {}
async execute(
input: ReopenRaceInput,
): Promise<Result<void, ApplicationErrorCode<ReopenRaceErrorCode, { message: string }>>> {
): Promise<Result<ReopenRaceResult, ApplicationErrorCode<ReopenRaceErrorCode, { message: string }>>> {
const { raceId } = input;
this.logger.debug(`[ReopenRaceUseCase] Executing for raceId: ${raceId}`);
@@ -60,9 +58,7 @@ export class ReopenRaceUseCase {
race: reopenedRace,
};
this.output.present(result);
return Result.ok(undefined);
return Result.ok(result);
} catch (error) {
if (error instanceof Error && error.message.includes('already scheduled')) {
this.logger.warn(`[ReopenRaceUseCase] Domain error re-opening race ${raceId}: ${error.message}`);
@@ -92,4 +88,4 @@ export class ReopenRaceUseCase {
});
}
}
}
}