29 lines
861 B
TypeScript
29 lines
861 B
TypeScript
/**
|
|
* TrackImageViewDataBuilder
|
|
*
|
|
* Transforms MediaBinaryDTO into TrackImageViewData for server-side rendering.
|
|
* Deterministic; side-effect free; no HTTP calls.
|
|
*/
|
|
|
|
import type { MediaBinaryDTO } from '@/lib/types/MediaBinaryDTO';
|
|
import type { TrackImageViewData } from '@/lib/view-data/TrackImageViewData';
|
|
|
|
import { ViewDataBuilder } from "../../contracts/builders/ViewDataBuilder";
|
|
|
|
export class TrackImageViewDataBuilder {
|
|
/**
|
|
* Transform API DTO to ViewData
|
|
*
|
|
* @param apiDto - The DTO from the service
|
|
* @returns ViewData for the track image
|
|
*/
|
|
public static build(apiDto: MediaBinaryDTO): TrackImageViewData {
|
|
return {
|
|
buffer: Buffer.from(apiDto.buffer).toString('base64'),
|
|
contentType: apiDto.contentType,
|
|
};
|
|
}
|
|
}
|
|
|
|
TrackImageViewDataBuilder satisfies ViewDataBuilder<MediaBinaryDTO, TrackImageViewData>;
|