refactor
This commit is contained in:
@@ -18,13 +18,18 @@ export interface GetAllRacesResult {
|
||||
export type GetAllRacesErrorCode = 'REPOSITORY_ERROR';
|
||||
|
||||
export class GetAllRacesUseCase {
|
||||
private output: UseCaseOutputPort<GetAllRacesResult> | null = null;
|
||||
|
||||
constructor(
|
||||
private readonly raceRepository: IRaceRepository,
|
||||
private readonly leagueRepository: ILeagueRepository,
|
||||
private readonly logger: Logger,
|
||||
private readonly output: UseCaseOutputPort<GetAllRacesResult>,
|
||||
) {}
|
||||
|
||||
setOutput(output: UseCaseOutputPort<GetAllRacesResult>) {
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
async execute(
|
||||
_input: GetAllRacesInput,
|
||||
): Promise<Result<void, ApplicationErrorCode<GetAllRacesErrorCode, { message: string }>>> {
|
||||
@@ -40,6 +45,9 @@ export class GetAllRacesUseCase {
|
||||
};
|
||||
|
||||
this.logger.debug('Successfully retrieved all races.');
|
||||
if (!this.output) {
|
||||
throw new Error('Output not set');
|
||||
}
|
||||
this.output.present(result);
|
||||
return Result.ok(undefined);
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user