You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

22 lines
900 B

import { listCards, type CardType } from "../../service/card";
import { getCurrentUser } from "#server/utils/context";
export default defineWrappedResponseHandler(async (event) => {
const query = getQuery(event);
const page = Math.max(1, parseInt(String(query.page || "1")));
const pageSize = Math.min(30, Math.max(1, parseInt(String(query.pageSize || "12"))));
const categoryId = query.categoryId as string | undefined;
const tagId = query.tagId ? parseInt(String(query.tagId)) : undefined;
const type = query.type as CardType | undefined;
const q = query.q as string | undefined;
const favorited = query.favorited === "true" || query.favorited === "1";
const user = await getCurrentUser(event);
const result = await listCards({
page, pageSize, categoryId, tagId, type, q,
favorited: favorited || undefined,
userId: user?.id,
});
return R.success(result);
});