refactor core presenters

This commit is contained in:
2025-12-19 19:42:19 +01:00
parent 8116fe888f
commit 94fc538f44
228 changed files with 2817 additions and 3097 deletions

View File

@@ -3,6 +3,7 @@ import type { IsDriverRegisteredForRaceQueryParamsDTO } from '../dto/RaceRegistr
import type { AsyncUseCase, Logger } from '@core/shared/application';
import { Result as SharedResult } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
import type { DriverRegistrationStatusOutputPort } from '../ports/output/DriverRegistrationStatusOutputPort';
type IsDriverRegisteredForRaceErrorCode = 'REPOSITORY_ERROR';
@@ -14,20 +15,20 @@ type IsDriverRegisteredForRaceApplicationError = ApplicationErrorCode<IsDriverRe
* Checks if a driver is registered for a specific race.
*/
export class IsDriverRegisteredForRaceUseCase
implements AsyncUseCase<IsDriverRegisteredForRaceQueryParamsDTO, boolean, IsDriverRegisteredForRaceErrorCode>
implements AsyncUseCase<IsDriverRegisteredForRaceQueryParamsDTO, DriverRegistrationStatusOutputPort, IsDriverRegisteredForRaceErrorCode>
{
constructor(
private readonly registrationRepository: IRaceRegistrationRepository,
private readonly logger: Logger,
) {}
async execute(params: IsDriverRegisteredForRaceQueryParamsDTO): Promise<SharedResult<boolean, IsDriverRegisteredForRaceApplicationError>> {
async execute(params: IsDriverRegisteredForRaceQueryParamsDTO): Promise<SharedResult<DriverRegistrationStatusOutputPort, IsDriverRegisteredForRaceApplicationError>> {
this.logger.debug('IsDriverRegisteredForRaceUseCase:execute', { params });
const { raceId, driverId } = params;
try {
const isRegistered = await this.registrationRepository.isRegistered(raceId, driverId);
return SharedResult.ok(isRegistered);
return SharedResult.ok({ isRegistered, raceId, driverId });
} catch (error) {
this.logger.error('IsDriverRegisteredForRaceUseCase:execution error', error instanceof Error ? error : new Error('Unknown error'));
return SharedResult.err({ code: 'REPOSITORY_ERROR', details: { message: error instanceof Error ? error.message : 'Unknown error' } });