refactor use cases
This commit is contained in:
@@ -4,7 +4,7 @@ import type { IResultRepository } from '../../domain/repositories/IResultReposit
|
||||
import type { IDriverRepository } from '../../domain/repositories/IDriverRepository';
|
||||
import type { IStandingRepository } from '../../domain/repositories/IStandingRepository';
|
||||
import { Result as RaceResult } from '../../domain/entities/result/Result';
|
||||
import type { Logger, UseCaseOutputPort } from '@core/shared/application';
|
||||
import type { Logger } from '@core/shared/application';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
|
||||
@@ -53,12 +53,11 @@ export class ImportRaceResultsApiUseCase {
|
||||
private readonly driverRepository: IDriverRepository,
|
||||
private readonly standingRepository: IStandingRepository,
|
||||
private readonly logger: Logger,
|
||||
private readonly output: UseCaseOutputPort<ImportRaceResultsApiResult>,
|
||||
) {}
|
||||
|
||||
async execute(
|
||||
input: ImportRaceResultsApiInput,
|
||||
): Promise<Result<void, ApplicationErrorCode<ImportRaceResultsApiErrorCode, { message: string }>>> {
|
||||
): Promise<Result<ImportRaceResultsApiResult, ApplicationErrorCode<ImportRaceResultsApiErrorCode, { message: string }>>> {
|
||||
const { raceId, resultsFileContent } = input;
|
||||
|
||||
this.logger.debug('ImportRaceResultsApiUseCase:execute', { raceId });
|
||||
@@ -187,9 +186,7 @@ export class ImportRaceResultsApiUseCase {
|
||||
errors: [],
|
||||
};
|
||||
|
||||
this.output.present(result);
|
||||
|
||||
return Result.ok(undefined);
|
||||
return Result.ok(result);
|
||||
} catch (error: unknown) {
|
||||
this.logger.error(
|
||||
'ImportRaceResultsApiUseCase:execution error',
|
||||
|
||||
Reference in New Issue
Block a user