优化路径,添加消息推送

This commit is contained in:
2026-04-17 12:14:57 +08:00
parent b8a842367b
commit 0da5936ce0
34 changed files with 2472 additions and 435 deletions
+29
View File
@@ -0,0 +1,29 @@
import { NextResponse } from "next/server";
import { removePushSubscription } from "@/lib/push";
import { getCaregiverSession } from "@/lib/session";
export async function POST(request: Request) {
const body = (await request.json().catch(() => null)) as
| {
endpoint?: string;
}
| null;
if (!body?.endpoint || typeof body.endpoint !== "string") {
return NextResponse.json({ error: "endpoint 是必填项。" }, { status: 400 });
}
const caregiver = await getCaregiverSession();
if (!caregiver) {
return NextResponse.json({ ok: true });
}
await removePushSubscription({
caregiverId: caregiver.id,
endpoint: body.endpoint,
});
return NextResponse.json({ ok: true });
}