refactor use cases
This commit is contained in:
@@ -2,7 +2,6 @@ import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
import type { IRaceRegistrationRepository } from '@core/racing/domain/repositories/IRaceRegistrationRepository';
|
||||
import type { IRaceRepository } from '@core/racing/domain/repositories/IRaceRepository';
|
||||
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
||||
import type { Logger } from '@core/shared/application/Logger';
|
||||
|
||||
export type WithdrawFromRaceInput = {
|
||||
@@ -30,11 +29,10 @@ export class WithdrawFromRaceUseCase {
|
||||
private readonly raceRepository: IRaceRepository,
|
||||
private readonly registrationRepository: IRaceRegistrationRepository,
|
||||
private readonly logger: Logger,
|
||||
private readonly output: UseCaseOutputPort<WithdrawFromRaceResult>,
|
||||
) {}
|
||||
|
||||
async execute(input: WithdrawFromRaceInput): Promise<
|
||||
Result<void, ApplicationErrorCode<WithdrawFromRaceErrorCode, { message: string }>>
|
||||
Result<WithdrawFromRaceResult, ApplicationErrorCode<WithdrawFromRaceErrorCode, { message: string }>>
|
||||
> {
|
||||
const { raceId, driverId } = input;
|
||||
|
||||
@@ -78,9 +76,7 @@ export class WithdrawFromRaceUseCase {
|
||||
status: 'withdrawn',
|
||||
};
|
||||
|
||||
this.output.present(result);
|
||||
|
||||
return Result.ok(undefined);
|
||||
return Result.ok(result);
|
||||
} catch (error) {
|
||||
const message =
|
||||
error instanceof Error ? error.message : 'Failed to withdraw from race';
|
||||
|
||||
Reference in New Issue
Block a user