Genesis
This commit is contained in:
23
src/endpoints/category.js
Normal file
23
src/endpoints/category.js
Normal 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,
|
||||
}))
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user