This commit is contained in:
seb
2026-07-06 01:31:11 +02:00
commit 917930d0fa
34 changed files with 2912 additions and 0 deletions

23
src/endpoints/category.js Normal file
View File

@@ -0,0 +1,23 @@
import { sendJson, serverTimestamp } from '../http.js';
import { getCategoryList } from '../queries/category-list.js';
export const method = 'GET';
export const path = '/v1/category';
export async function handle(_req, res, { url }) {
const cursor = Number(url.searchParams.get('lastChangedCategory')) || 0;
const limit = Number(url.searchParams.get('limit')) || 20;
const categories = await getCategoryList({ cursor, limit });
const timestamp = serverTimestamp();
return sendJson(
res,
200,
categories.map((category) => ({
...category,
updated_at: timestamp,
created_at: timestamp,
}))
);
}