next/server/api/story/[id]/[chapter]/reviews/index.get.ts

11 lines
310 B
TypeScript

import { storyQuerier } from "@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();
});