16 lines
648 B
TypeScript
16 lines
648 B
TypeScript
import { getNotifyPrefs } from "@peppa/core";
|
|
import { currentUser } from "@/lib/auth";
|
|
import { db } from "@/lib/db";
|
|
import { navCounts } from "@/lib/queries";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
/** What waits for the signed-in user (tab title counter and app badge, PEP-55). */
|
|
export async function GET() {
|
|
const user = await currentUser();
|
|
if (!user) return Response.json({ error: "unauthorized" }, { status: 401 });
|
|
const c = await navCounts(user.id);
|
|
const { sound } = await getNotifyPrefs(db, user.id);
|
|
return Response.json({ count: c.questions + c.waitingRunners, sound }, { headers: { "Cache-Control": "no-store" } });
|
|
}
|