Files
mnote/wolai-frontend/src/app/api/mindmap-trash/empty/route.ts
T

31 lines
1.0 KiB
TypeScript
Raw Normal View History

2026-01-10 10:35:21 +08:00
import { NextResponse } from "next/server";
2026-01-17 10:12:53 +08:00
import { isConvexEnabled } from "@/lib/convex/enabled";
import { getAuthedConvexClient } from "@/lib/convex/route";
import { api } from "@/lib/convex/api";
2026-01-10 10:35:21 +08:00
export const dynamic = "force-dynamic";
interface EmptyTrashPayload {
workspaceId?: string;
}
export async function POST(request: Request) {
2026-01-17 10:12:53 +08:00
if (isConvexEnabled()) {
2026-01-18 19:01:31 +08:00
const { client } = await getAuthedConvexClient();
2026-01-17 10:12:53 +08:00
const { workspaceId }: EmptyTrashPayload = await request.json().catch(() => ({}));
if (!workspaceId) {
return NextResponse.json({ error: "缺少 workspaceId" }, { status: 400 });
}
try {
2026-01-18 19:01:31 +08:00
const result = await client.mutation(api.mindmaps.emptyTrashByWorkspace, { workspaceId });
2026-01-17 10:12:53 +08:00
return NextResponse.json({ ok: true, removed: result?.deletedCount ?? 0 });
} catch (error) {
return NextResponse.json({ error: (error as Error).message }, { status: 400 });
}
}
2026-01-18 19:01:31 +08:00
return NextResponse.json({ error: "当前仅支持 Convex 模式" }, { status: 501 });
2026-01-10 10:35:21 +08:00
}
2026-01-18 19:01:31 +08:00