- Spotify playlist, library, album and artist browsing with in-app playback - Song, playlist and album downloads via spotdl with YouTube and Bandcamp fallbacks - Electron desktop app (castLabs Widevine) with a permanent sidebar layout - Linux and Windows packaging scripts
30 lines
835 B
TypeScript
30 lines
835 B
TypeScript
import { z } from "zod";
|
|
import superjson from "superjson";
|
|
|
|
export const schema = z.object({
|
|
title: z.string().min(1),
|
|
artist: z.string().min(1),
|
|
album: z.string().optional(),
|
|
durationMs: z.number().nonnegative().optional(),
|
|
});
|
|
|
|
export type InputType = z.infer<typeof schema>;
|
|
export type OutputType = {
|
|
plain?: string;
|
|
synced?: string;
|
|
instrumental?: boolean;
|
|
};
|
|
|
|
export async function postLyrics(body: InputType): Promise<OutputType> {
|
|
const response = await fetch("/_api/lyrics", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: superjson.stringify(schema.parse(body)),
|
|
});
|
|
if (!response.ok) {
|
|
const parsed = superjson.parse<{ error: string }>(await response.text());
|
|
throw new Error(parsed.error);
|
|
}
|
|
return superjson.parse<OutputType>(await response.text());
|
|
}
|