website refactor
This commit is contained in:
@@ -1,13 +1,75 @@
|
||||
/**
|
||||
* Media Service - DTO Only
|
||||
* MediaService
|
||||
*
|
||||
* Returns raw API DTOs. No ViewModels or UX logic.
|
||||
* All client-side presentation logic must be handled by hooks/components.
|
||||
* Frontend orchestration service for media operations.
|
||||
* Handles binary media fetching with proper error handling.
|
||||
*/
|
||||
export class MediaService {
|
||||
constructor(private readonly apiClient: any) {}
|
||||
|
||||
async getMediaById(mediaId: string): Promise<any> {
|
||||
return { id: mediaId, url: '' };
|
||||
import { Result } from '@/lib/contracts/Result';
|
||||
import { Service, DomainError } from '@/lib/contracts/services/Service';
|
||||
import { MediaAdapter } from '@/lib/adapters/MediaAdapter';
|
||||
import { MediaBinaryDTO } from '@/lib/types/MediaBinaryDTO';
|
||||
|
||||
/**
|
||||
* MediaService
|
||||
*
|
||||
* Handles media asset fetching with proper error handling.
|
||||
* Creates its own dependencies and orchestrates adapter calls.
|
||||
*/
|
||||
export class MediaService implements Service {
|
||||
private adapter: MediaAdapter;
|
||||
|
||||
constructor() {
|
||||
// Service creates its own dependencies
|
||||
this.adapter = new MediaAdapter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get avatar for a driver
|
||||
*/
|
||||
async getAvatar(driverId: string): Promise<Result<MediaBinaryDTO, DomainError>> {
|
||||
return this.adapter.fetchMedia(`/media/avatar/${driverId}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get category icon
|
||||
*/
|
||||
async getCategoryIcon(categoryId: string): Promise<Result<MediaBinaryDTO, DomainError>> {
|
||||
return this.adapter.fetchMedia(`/media/categories/${categoryId}/icon`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get league cover
|
||||
*/
|
||||
async getLeagueCover(leagueId: string): Promise<Result<MediaBinaryDTO, DomainError>> {
|
||||
return this.adapter.fetchMedia(`/media/leagues/${leagueId}/cover`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get league logo
|
||||
*/
|
||||
async getLeagueLogo(leagueId: string): Promise<Result<MediaBinaryDTO, DomainError>> {
|
||||
return this.adapter.fetchMedia(`/media/leagues/${leagueId}/logo`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sponsor logo
|
||||
*/
|
||||
async getSponsorLogo(sponsorId: string): Promise<Result<MediaBinaryDTO, DomainError>> {
|
||||
return this.adapter.fetchMedia(`/media/sponsors/${sponsorId}/logo`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get team logo
|
||||
*/
|
||||
async getTeamLogo(teamId: string): Promise<Result<MediaBinaryDTO, DomainError>> {
|
||||
return this.adapter.fetchMedia(`/media/teams/${teamId}/logo`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get track image
|
||||
*/
|
||||
async getTrackImage(trackId: string): Promise<Result<MediaBinaryDTO, DomainError>> {
|
||||
return this.adapter.fetchMedia(`/media/tracks/${trackId}/image`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user