1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import { withErrors, ok } from "@/lib/api";
import { requireUser } from "@/lib/auth";
import { db } from "@/db";
import { sources } from "@/db/schema";
import { eq } from "drizzle-orm";
import { CiderConfig } from "@/lib/schemas/sources/cider";
export const POST = withErrors(async (req) => {
await requireUser(req);
const row = db.select().from(sources).where(eq(sources.kind, "cider")).get();
if (!row) return ok({ error: "no cider source" });
const config = CiderConfig.parse(row.config);
const res = await fetch(`${config.host}/api/v1/playback/next`, {
method: "POST",
headers: { apptoken: config.appToken },
});
if (!res.ok) throw new Error(`Cider ${res.status}`);
return ok({ ok: true });
});
|