services refactor

This commit is contained in:
2025-12-17 22:17:02 +01:00
parent 26f7a2b6aa
commit 055a7f67b5
93 changed files with 7434 additions and 659 deletions

View File

@@ -1,6 +1,53 @@
import { api as api } from '../../api';
import type { MediaApiClient } from '../../api/media/MediaApiClient';
import type { MediaPresenter } from '../../presenters/MediaPresenter';
import type { UploadMediaInputDto, GetMediaOutputDto, DeleteMediaOutputDto } from '../../dtos';
import type { MediaViewModel, UploadMediaViewModel, DeleteMediaViewModel } from '../../view-models';
export async function uploadMedia(file: any): Promise<any> {
// TODO: implement
return {};
/**
* Media Service
*
* Orchestrates media operations by coordinating API calls and presentation logic.
* All dependencies are injected via constructor.
*/
export class MediaService {
constructor(
private readonly apiClient: MediaApiClient,
private readonly presenter: MediaPresenter
) {}
/**
* Upload media file with presentation transformation
*/
async uploadMedia(input: UploadMediaInputDto): Promise<UploadMediaViewModel> {
try {
const dto = await this.apiClient.uploadMedia(input);
return this.presenter.presentUpload(dto);
} catch (error) {
throw error;
}
}
/**
* Get media by ID with presentation transformation
*/
async getMedia(mediaId: string): Promise<MediaViewModel> {
try {
const dto = await this.apiClient.getMedia(mediaId);
return this.presenter.presentMedia(dto);
} catch (error) {
throw error;
}
}
/**
* Delete media by ID with presentation transformation
*/
async deleteMedia(mediaId: string): Promise<DeleteMediaViewModel> {
try {
const dto = await this.apiClient.deleteMedia(mediaId);
return this.presenter.presentDelete(dto);
} catch (error) {
throw error;
}
}
}