refactor driver module (wip)

This commit is contained in:
2025-12-22 01:43:34 +01:00
parent b445d6dd37
commit e7dbec4a85
31 changed files with 379 additions and 395 deletions

View File

@@ -1,10 +1,18 @@
import { Result } from '@core/shared/application/Result';
import type { Driver } from '@core/racing/domain/entities/Driver';
import type { GetDriverOutputDTO } from '../dtos/GetDriverOutputDTO';
export class DriverPresenter {
private responseModel: GetDriverOutputDTO | null = null;
present(driver: Driver | null): void {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
present(result: Result<Driver | null, any>): void {
if (result.isErr()) {
const error = result.unwrapErr();
throw new Error(error.details?.message ?? 'Failed to get driver');
}
const driver = result.unwrap();
if (!driver) {
this.responseModel = null;
return;
@@ -15,8 +23,8 @@ export class DriverPresenter {
iracingId: driver.iracingId.toString(),
name: driver.name.toString(),
country: driver.country.toString(),
bio: driver.bio?.toString(),
joinedAt: driver.joinedAt.toDate().toISOString(),
...(driver.bio ? { bio: driver.bio.toString() } : {}),
};
}