refactor use cases
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import type { UseCaseOutputPort } from '@core/shared/application';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
import type { Driver } from '../../domain/entities/Driver';
|
||||
@@ -29,13 +28,12 @@ export class GetLeagueStandingsUseCase {
|
||||
constructor(
|
||||
private readonly standingRepository: IStandingRepository,
|
||||
private readonly driverRepository: IDriverRepository,
|
||||
private readonly output: UseCaseOutputPort<GetLeagueStandingsResult>,
|
||||
) {}
|
||||
|
||||
async execute(
|
||||
input: GetLeagueStandingsInput,
|
||||
): Promise<
|
||||
Result<void, ApplicationErrorCode<GetLeagueStandingsErrorCode, { message: string }>>
|
||||
Result<GetLeagueStandingsResult, ApplicationErrorCode<GetLeagueStandingsErrorCode, { message: string }>>
|
||||
> {
|
||||
try {
|
||||
const standings = await this.standingRepository.findByLeagueId(input.leagueId);
|
||||
@@ -56,9 +54,7 @@ export class GetLeagueStandingsUseCase {
|
||||
})),
|
||||
};
|
||||
|
||||
this.output.present(result);
|
||||
|
||||
return Result.ok(undefined);
|
||||
return Result.ok(result);
|
||||
} catch (error) {
|
||||
return Result.err({
|
||||
code: 'REPOSITORY_ERROR',
|
||||
|
||||
Reference in New Issue
Block a user