fix: decduck's code review

This commit is contained in:
DecDuck
2025-03-10 11:39:45 +11:00
parent 31aaec74af
commit 1ce707788d
17 changed files with 274 additions and 94 deletions

View File

@ -1,21 +1,20 @@
import { defineEventHandler, createError, readBody } from "h3";
import aclManager from "~/server/internal/acls";
import newsManager from "~/server/internal/news";
export default defineEventHandler(async (event) => {
const body = await readBody(event);
if (!body.authorId) {
throw createError({
statusCode: 400,
message: 'Author ID is required'
});
}
export default defineEventHandler(async (h3) => {
const allowed = await aclManager.allowSystemACL(h3, ["news:create"]);
if (!allowed) throw createError({ statusCode: 403 });
const body = await readBody(h3);
const article = await newsManager.create({
title: body.title,
description: body.description,
content: body.content,
excerpt: body.excerpt,
tags: body.tags,
image: body.image,
authorId: body.authorId,
});