feat(api): Added API for retriving information about a spesific news article

This commit is contained in:
Aden Lindsay
2025-02-02 10:21:10 +10:30
committed by GitHub
parent 2ef8f2f93c
commit 1286248207

View File

@ -0,0 +1,22 @@
import { defineEventHandler, createError } from "h3";
import newsManager from "~/server/internal/news";
export default defineEventHandler(async (event) => {
const id = event.context.params?.id;
if (!id) {
throw createError({
statusCode: 400,
message: "Missing news ID",
});
}
const news = await newsManager.getById(id);
if (!news) {
throw createError({
statusCode: 404,
message: "News article not found",
});
}
return news;
});