refactor use cases
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import type { Logger } from '@core/shared/application';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
import type { Race } from '../../domain/entities/Race';
|
||||
import type { ILeagueRepository } from '../../domain/repositories/ILeagueRepository';
|
||||
@@ -27,12 +26,11 @@ export class GetRacesPageDataUseCase {
|
||||
private readonly raceRepository: IRaceRepository,
|
||||
private readonly leagueRepository: ILeagueRepository,
|
||||
private readonly logger: Logger,
|
||||
private readonly output: UseCaseOutputPort<GetRacesPageDataResult>,
|
||||
) {}
|
||||
|
||||
async execute(
|
||||
input: GetRacesPageDataInput,
|
||||
): Promise<Result<void, ApplicationErrorCode<GetRacesPageDataErrorCode, { message: string }>>> {
|
||||
): Promise<Result<GetRacesPageDataResult, ApplicationErrorCode<GetRacesPageDataErrorCode, { message: string }>>> {
|
||||
this.logger.debug('GetRacesPageDataUseCase:execute', { input });
|
||||
|
||||
try {
|
||||
@@ -61,9 +59,7 @@ export class GetRacesPageDataUseCase {
|
||||
races,
|
||||
};
|
||||
|
||||
this.output.present(result);
|
||||
|
||||
return Result.ok(undefined);
|
||||
return Result.ok(result);
|
||||
} catch (error: unknown) {
|
||||
const message =
|
||||
error instanceof Error && error.message
|
||||
@@ -81,4 +77,4 @@ export class GetRacesPageDataUseCase {
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user