next/server/api/user/[id]/stories.get.ts
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 96a0d36bef
fix(api): update user stories endpoint
it now takes into account the new return type for `listQuerier`
2023-12-06 21:52:04 -05:00

12 lines
331 B
TypeScript

import listQuerier from "~/lib/server/dbHelpers/listQuerier";
export default cachedEventHandler(async (ev) => {
const id = parseInt(getRouterParam(ev, "id")!);
let s = await listQuerier({ author: { $in: [id] } }, ev.context, ev);
const t = s.stories.map((a) => a.toObject());
return {
stories: t,
total: t.length,
};
});