next/server/api/story/[id]/[chapter]/reviews/index.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
316 B
TypeScript

import { storyQuerier } from "~/lib/server/dbHelpers";
import { Review } from "~/models/stories/review";
export default eventHandler(async (ev) => {
let story = await storyQuerier(ev);
return await Review.find({
whichChapter: story.chapters[ev.context.chapterIndex || 0].id,
replyingTo: null,
}).exec();
});