카테고리 순서 변경 api
This commit is contained in:
@@ -24,7 +24,11 @@ const updateSchema = z.object({
|
||||
export async function PATCH(req: Request, context: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await context.params;
|
||||
const userId = getUserIdFromRequest(req);
|
||||
await requirePermission({ userId, resource: "POST", action: "UPDATE" });
|
||||
try {
|
||||
await requirePermission({ userId, resource: "POST", action: "UPDATE" });
|
||||
} catch (e) {
|
||||
return NextResponse.json({ error: "Forbidden" }, { status: 403 });
|
||||
}
|
||||
const body = await req.json();
|
||||
const parsed = updateSchema.safeParse(body);
|
||||
if (!parsed.success) return NextResponse.json({ error: parsed.error.flatten() }, { status: 400 });
|
||||
@@ -35,7 +39,11 @@ export async function PATCH(req: Request, context: { params: Promise<{ id: strin
|
||||
export async function DELETE(req: Request, context: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await context.params;
|
||||
const userId = getUserIdFromRequest(req);
|
||||
await requirePermission({ userId, resource: "POST", action: "DELETE" });
|
||||
try {
|
||||
await requirePermission({ userId, resource: "POST", action: "DELETE" });
|
||||
} catch (e) {
|
||||
return NextResponse.json({ error: "Forbidden" }, { status: 403 });
|
||||
}
|
||||
const post = await prisma.post.update({ where: { id }, data: { status: "deleted" } });
|
||||
return NextResponse.json({ post });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user