website refactor
This commit is contained in:
36
apps/website/lib/page-queries/media/GetTeamLogoPageQuery.ts
Normal file
36
apps/website/lib/page-queries/media/GetTeamLogoPageQuery.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* GetTeamLogoPageQuery
|
||||
*
|
||||
* Server-side composition for team logo media route.
|
||||
*/
|
||||
|
||||
import { PageQuery } from '@/lib/contracts/page-queries/PageQuery';
|
||||
import { Result } from '@/lib/contracts/Result';
|
||||
import { MediaService } from '@/lib/services/media/MediaService';
|
||||
import { TeamLogoViewDataBuilder } from '@/lib/builders/view-data/TeamLogoViewDataBuilder';
|
||||
import { TeamLogoViewData } from '@/lib/view-data/TeamLogoViewData';
|
||||
import { PresentationError, mapToPresentationError } from '@/lib/contracts/page-queries/PresentationError';
|
||||
|
||||
export class GetTeamLogoPageQuery implements PageQuery<TeamLogoViewData, { teamId: string }> {
|
||||
async execute(params: { teamId: string }): Promise<Result<TeamLogoViewData, PresentationError>> {
|
||||
try {
|
||||
const service = new MediaService();
|
||||
const apiDtoResult = await service.getTeamLogo(params.teamId);
|
||||
|
||||
if (apiDtoResult.isErr()) {
|
||||
return Result.err(mapToPresentationError(apiDtoResult.getError()));
|
||||
}
|
||||
|
||||
const output = TeamLogoViewDataBuilder.build(apiDtoResult.unwrap());
|
||||
return Result.ok(output);
|
||||
} catch (err) {
|
||||
console.error('GetTeamLogoPageQuery failed:', err);
|
||||
return Result.err('serverError');
|
||||
}
|
||||
}
|
||||
|
||||
static async execute(params: { teamId: string }): Promise<Result<TeamLogoViewData, PresentationError>> {
|
||||
const query = new GetTeamLogoPageQuery();
|
||||
return query.execute(params);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user