Files
gridpilot.gg/core/racing/application/use-cases/GetDriverUseCase.ts
2026-01-16 16:46:57 +01:00

21 lines
664 B
TypeScript

import { Result } from '@core/shared/domain/Result';
import type { Driver } from '../../domain/entities/Driver';
import type { DriverRepository } from '../../domain/repositories/DriverRepository';
export type GetDriverInput = {
driverId: string;
};
export class GetDriverUseCase {
constructor(private readonly driverRepository: DriverRepository) {}
async execute(input: GetDriverInput): Promise<Result<Driver | null>> {
try {
const driver = await this.driverRepository.findById(input.driverId);
return Result.ok(driver);
} catch (error) {
return Result.err(error instanceof Error ? error : new Error(String(error)));
}
}
}