Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-05-04 08:30:15 +03:00
commit 75e03b42f7
99 files changed
+12285

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
import { prisma } from "@/lib/db";
import { requireDm } from "@/lib/session";
import { json, err, asResponse } from "@/lib/api";
export const dynamic = "force-dynamic";
export async function GET() {
try {
await requireDm();
const rows = await prisma.thread.findMany({
where: { resolved: false },
orderBy: [{ primary: "desc" }, { createdAt: "desc" }],
});
return json(rows);
} catch (e) {
return asResponse(e);
}
}
export async function POST(req: Request) {
try {
await requireDm();
const b = (await req.json()) as Partial<{ text: string; who: string; primary: boolean }>;
if (!b.text) return err("text required");
const t = await prisma.thread.create({
data: { text: b.text, who: b.who ?? "", primary: !!b.primary },
});
return json(t, { status: 201 });
} catch (e) {
return asResponse(e);
}
}