first commit

This commit is contained in:
luoyangwei
2026-06-06 00:49:07 +08:00
commit 2b860d201e
134 changed files with 22773 additions and 0 deletions
@@ -0,0 +1,52 @@
import { getAppUserFromRequest } from "@/server/app/app-auth";
import { removeUserFavorite } from "@/server/app/user-favorites";
import { NextResponse } from "next/server";
import { z } from "zod";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
const paramsSchema = z.object({
photoId: z.uuid(),
});
export async function DELETE(
request: Request,
{ params }: { params: Promise<{ photoId: string }> },
) {
try {
const user = await getAppUserFromRequest(request);
if (!user) {
return NextResponse.json(
{ ok: false, error: "Unauthorized." },
{ status: 401 },
);
}
const parsed = paramsSchema.safeParse(await params);
if (!parsed.success) {
return NextResponse.json(
{ ok: false, error: "Invalid photo id." },
{ status: 400 },
);
}
await removeUserFavorite({
userId: user.id,
photoId: parsed.data.photoId,
});
return NextResponse.json({
ok: true,
});
} catch (error) {
const message =
error instanceof Error ? error.message : "Unknown error.";
return NextResponse.json(
{ ok: false, error: message },
{ status: 500 },
);
}
}