next/server/api/user/[id]/stories.get.ts
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 088232f750
refactor(api & server/utils): refactor imports of db helpers
create an index file which exports the functions we need in one accessible place
2023-12-11 21:29:46 -05:00

11 lines
292 B
TypeScript

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