mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-07-27 02:04:39 +10:00
feat(api): Added API for fetching news articles
This commit is contained in:
@@ -0,0 +1,17 @@
|
|||||||
|
import { defineEventHandler, getQuery } from "h3";
|
||||||
|
import newsManager from "~/server/internal/news";
|
||||||
|
|
||||||
|
export default defineEventHandler(async (event) => {
|
||||||
|
const query = getQuery(event);
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
take: query.limit ? parseInt(query.limit as string) : undefined,
|
||||||
|
skip: query.skip ? parseInt(query.skip as string) : undefined,
|
||||||
|
orderBy: query.order as 'asc' | 'desc',
|
||||||
|
tags: query.tags ? (query.tags as string).split(',') : undefined,
|
||||||
|
search: query.search as string,
|
||||||
|
};
|
||||||
|
|
||||||
|
const news = await newsManager.getAll(options);
|
||||||
|
return news;
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user