mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-13 00:02:37 +10:00
24 lines
613 B
TypeScript
24 lines
613 B
TypeScript
import { defineEventHandler, createError, readBody } from "h3";
|
|
import aclManager from "~/server/internal/acls";
|
|
import newsManager from "~/server/internal/news";
|
|
|
|
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,
|
|
|
|
tags: body.tags,
|
|
|
|
image: body.image,
|
|
authorId: body.authorId,
|
|
});
|
|
|
|
return article;
|
|
});
|