/** * Application Use Case: GetSponsorsUseCase * * Retrieves all sponsors. */ import type { ISponsorRepository } from '../../domain/repositories/ISponsorRepository'; import type { Sponsor } from '../../domain/entities/sponsor/Sponsor'; import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort'; import { Result } from '@core/shared/application/Result'; import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode'; type GetSponsorsResult = { sponsors: Sponsor[]; }; export class GetSponsorsUseCase { constructor( private readonly sponsorRepository: ISponsorRepository, private readonly output: UseCaseOutputPort, ) {} async execute(): Promise>> { try { const sponsors = await this.sponsorRepository.findAll(); this.output.present({ sponsors }); return Result.ok(undefined); } catch { return Result.err({ code: 'REPOSITORY_ERROR', message: 'Failed to fetch sponsors' }); } } }