Files
drop/server/api/v1/admin/news/index.post.ts
2025-03-10 11:39:45 +11:00

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;
});