Files
Aurora-SpotiRip/endpoints/spotify-download-status_GET.schema.ts
T

28 lines
838 B
TypeScript
Raw Normal View History

2026-09-25 23:20:57 -05:00
import superjson from "superjson";
export type OutputType = {
status: "running" | "ready" | "failed";
done: number;
total: number;
failed: number;
currentTitle?: string;
error?: string;
fileName?: string;
savedPath?: string;
};
export async function getSpotifyDownloadStatus(jobId: string): Promise<OutputType> {
const response = await fetch(`/_api/spotify-download-status?jobId=${encodeURIComponent(jobId)}`, {
cache: "no-store",
});
if (!response.ok) {
const parsed = (await response.json().catch(() => ({}))) as { error?: string };
throw new Error(parsed.error || "Unable to check the download.");
}
return superjson.parse<OutputType>(await response.text());
}
export function spotifyDownloadFileUrl(jobId: string) {
return `/_api/spotify-download-file?jobId=${encodeURIComponent(jobId)}`;
}