refactor core presenters
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import type { ISponsorRepository } from '../../domain/repositories/ISponsorRepository';
|
||||
import type { GetSponsorsViewModel } from '../presenters/IGetSponsorsPresenter';
|
||||
import type { GetSponsorsOutputPort } from '../ports/output/GetSponsorsOutputPort';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
|
||||
@@ -14,11 +14,11 @@ export class GetSponsorsUseCase {
|
||||
private readonly sponsorRepository: ISponsorRepository,
|
||||
) {}
|
||||
|
||||
async execute(): Promise<Result<GetSponsorsViewModel, ApplicationErrorCode<'REPOSITORY_ERROR'>>> {
|
||||
async execute(): Promise<Result<GetSponsorsOutputPort, ApplicationErrorCode<'REPOSITORY_ERROR'>>> {
|
||||
try {
|
||||
const sponsors = await this.sponsorRepository.findAll();
|
||||
|
||||
const viewModel: GetSponsorsViewModel = {
|
||||
const outputPort: GetSponsorsOutputPort = {
|
||||
sponsors: sponsors.map(sponsor => ({
|
||||
id: sponsor.id,
|
||||
name: sponsor.name,
|
||||
@@ -29,7 +29,7 @@ export class GetSponsorsUseCase {
|
||||
})),
|
||||
};
|
||||
|
||||
return Result.ok(viewModel);
|
||||
return Result.ok(outputPort);
|
||||
} catch {
|
||||
return Result.err({ code: 'REPOSITORY_ERROR', message: 'Failed to fetch sponsors' });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user