next/server/api/user/[id]/stories.get.ts

12 lines
331 B
TypeScript
Raw Normal View History

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,
};
});