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

12 lines
344 B
TypeScript
Raw Normal View History

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