mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-13 08:12:40 +10:00
fix: decduck's code review
This commit is contained in:
@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user