website refactor
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
import { DeleteMediaViewModel } from '@/lib/view-models/DeleteMediaViewModel';
|
||||
import { MediaViewModel } from '@/lib/view-models/MediaViewModel';
|
||||
import { UploadMediaViewModel } from '@/lib/view-models/UploadMediaViewModel';
|
||||
import type { MediaApiClient } from '../../api/media/MediaApiClient';
|
||||
|
||||
// Local request shape mirroring the media upload API contract until a generated type is available
|
||||
type UploadMediaRequest = { file: File; type: string; category?: string };
|
||||
|
||||
/**
|
||||
* Media Service
|
||||
*
|
||||
* Orchestrates media operations by coordinating API calls and view model creation.
|
||||
* All dependencies are injected via constructor.
|
||||
*/
|
||||
export class MediaService {
|
||||
constructor(
|
||||
private readonly apiClient: MediaApiClient
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Upload media file with view model transformation
|
||||
*/
|
||||
async uploadMedia(input: UploadMediaRequest): Promise<UploadMediaViewModel> {
|
||||
const dto = await this.apiClient.uploadMedia(input);
|
||||
return new UploadMediaViewModel(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get media by ID with view model transformation
|
||||
*/
|
||||
async getMedia(mediaId: string): Promise<MediaViewModel> {
|
||||
const dto = await this.apiClient.getMedia(mediaId);
|
||||
return new MediaViewModel(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete media by ID with view model transformation
|
||||
*/
|
||||
async deleteMedia(mediaId: string): Promise<DeleteMediaViewModel> {
|
||||
const dto = await this.apiClient.deleteMedia(mediaId);
|
||||
return new DeleteMediaViewModel(dto);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user