Bloc A - Code mort: - Suppression Studio (components, views, features) - Suppression gamification + services mock (projectService, storageService, gamificationService) - Mise à jour Sidebar, Navbar, locales Bloc B - Frontend: - Suppression modal.tsx deprecated, Modal.stories (doublon Dialog) - Feature flags: PLAYLIST_SEARCH, PLAYLIST_RECOMMENDATIONS, ROLE_MANAGEMENT = true - Suppression 19 tests orphelins, retrait exclusions vitest.config Bloc C - Backend: - Extraction routes_auth.go depuis router.go Bloc D - Rust: - Suppression security_legacy.rs (code mort, patterns déjà dans security/)
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
/**
|
|
* Live Service
|
|
* Live stream metadata — calls backend API
|
|
*/
|
|
|
|
import { apiClient } from './api/client';
|
|
import type { LiveStream } from '@/types';
|
|
|
|
function mapApiToLiveStream(api: Record<string, unknown>): LiveStream {
|
|
const tags = api.tags;
|
|
return {
|
|
id: String(api.id ?? ''),
|
|
title: String(api.title ?? ''),
|
|
streamer: String(api.streamer ?? api.streamerName ?? ''),
|
|
viewers: Number(api.viewers ?? api.viewerCount ?? 0),
|
|
thumbnailUrl: String(api.thumbnailUrl ?? ''),
|
|
tags: Array.isArray(tags) ? (tags as string[]) : [],
|
|
isLive: Boolean(api.isLive ?? api.is_live ?? false),
|
|
category: (api.category as LiveStream['category']) ?? 'Production',
|
|
};
|
|
}
|
|
|
|
export const liveService = {
|
|
async listStreams(isLive?: boolean): Promise<LiveStream[]> {
|
|
const params = isLive != null ? { is_live: String(isLive) } : {};
|
|
const response = await apiClient.get<{ streams: Record<string, unknown>[] }>(
|
|
'/live/streams',
|
|
{ params },
|
|
);
|
|
const streams = response.data?.streams ?? [];
|
|
return Array.isArray(streams) ? streams.map(mapApiToLiveStream) : [];
|
|
},
|
|
|
|
async getStream(id: string): Promise<LiveStream | null> {
|
|
const response = await apiClient.get<{ stream: Record<string, unknown> }>(
|
|
`/live/streams/${id}`,
|
|
);
|
|
const stream = response.data?.stream;
|
|
if (!stream) return null;
|
|
return mapApiToLiveStream(stream);
|
|
},
|
|
};
|