All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 42s
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
21 lines
723 B
TypeScript
21 lines
723 B
TypeScript
import { Router } from "@oak/oak";
|
|
import { resolveYouTubePlaylist } from "../services/youtube-playlist-service.ts";
|
|
|
|
const youtubeRouter = new Router();
|
|
|
|
/**
|
|
* Resolve a YouTube playlist ID to its tracklist (titles and lengths).
|
|
*
|
|
* Public, like /api/bandcamp/tracks: it only reads a public page. The client
|
|
* treats any failure as "show the embed without a tracklist".
|
|
*/
|
|
youtubeRouter.get("/api/youtube/playlist", async (ctx) => {
|
|
const listId = ctx.request.url.searchParams.get("list") ?? "";
|
|
const playlist = await resolveYouTubePlaylist(listId);
|
|
|
|
ctx.response.headers.set("Cache-Control", "public, max-age=3600");
|
|
ctx.response.body = { success: true, data: playlist };
|
|
});
|
|
|
|
export default youtubeRouter;
|