All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 50s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
881 B
TypeScript
26 lines
881 B
TypeScript
import { Router } from "@oak/oak";
|
|
import type { APIResponse } from "../../shared/api.ts";
|
|
import { resolveYouTubePlaylist } from "../remote/youtube-playlist.ts";
|
|
import type { YouTubePlaylist } from "../../shared/player.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 responseBody: APIResponse<YouTubePlaylist> = {
|
|
success: true,
|
|
data: await resolveYouTubePlaylist(listId),
|
|
};
|
|
|
|
ctx.response.headers.set("Cache-Control", "public, max-age=3600");
|
|
ctx.response.body = responseBody;
|
|
});
|
|
|
|
export default youtubeRouter;
|