feat(frontend): rework audio player and shared UI components
Expand the player store, split player controls (transport, seek, volume, track info), add Cover/PlaylistArt/NowPlaying UI primitives and a cover image proxy route.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import type { RequestHandler } from './$types';
|
||||
import { apiConfig } from '$lib/server/config';
|
||||
|
||||
const ALLOWED = new Set(['small', 'medium', 'large']);
|
||||
|
||||
export const GET: RequestHandler = async ({ params, url, fetch }) => {
|
||||
const size = url.searchParams.get('size') ?? 'medium';
|
||||
const safeSize = ALLOWED.has(size) ? size : 'medium';
|
||||
|
||||
const upstream = await fetch(
|
||||
`${apiConfig.baseUrl}/tracks/${params.id}/cover?size=${safeSize}`
|
||||
);
|
||||
|
||||
if (!upstream.ok) {
|
||||
return new Response(null, { status: upstream.status });
|
||||
}
|
||||
|
||||
return new Response(upstream.body, {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': upstream.headers.get('content-type') ?? 'image/webp',
|
||||
'Cache-Control': 'public, max-age=86400'
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user