refactor use cases
This commit is contained in:
@@ -10,7 +10,7 @@ import type { IPenaltyRepository } from '../../domain/repositories/IPenaltyRepos
|
||||
import type { IRaceRepository } from '../../domain/repositories/IRaceRepository';
|
||||
import type { ILeagueMembershipRepository } from '../../domain/repositories/ILeagueMembershipRepository';
|
||||
import { randomUUID } from 'crypto';
|
||||
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';
|
||||
|
||||
@@ -42,10 +42,9 @@ export class QuickPenaltyUseCase {
|
||||
private readonly raceRepository: IRaceRepository,
|
||||
private readonly leagueMembershipRepository: ILeagueMembershipRepository,
|
||||
private readonly logger: Logger,
|
||||
private readonly output: UseCaseOutputPort<QuickPenaltyResult>,
|
||||
) {}
|
||||
|
||||
async execute(input: QuickPenaltyInput): Promise<Result<void, QuickPenaltyApplicationError>> {
|
||||
async execute(input: QuickPenaltyInput): Promise<Result<QuickPenaltyResult, QuickPenaltyApplicationError>> {
|
||||
this.logger.debug('Executing QuickPenaltyUseCase', { input });
|
||||
|
||||
try {
|
||||
@@ -111,10 +110,8 @@ export class QuickPenaltyUseCase {
|
||||
reason,
|
||||
};
|
||||
|
||||
this.output.present(result);
|
||||
|
||||
this.logger.info('Quick penalty applied successfully', { penaltyId: penalty.id, raceId: input.raceId, driverId: input.driverId });
|
||||
return Result.ok(undefined);
|
||||
return Result.ok(result);
|
||||
} catch (error: unknown) {
|
||||
const err =
|
||||
error instanceof Error ? error : new Error('Failed to apply quick penalty');
|
||||
|
||||
Reference in New Issue
Block a user