mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-10 04:22:09 +10:00
feat(api): Added API for fetching news articles
This commit is contained in:
17
server/api/v1/news/index.get.ts
Normal file
17
server/api/v1/news/index.get.ts
Normal file
@ -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