next/server/api/story/[id]/[chapter]/reviews/index.get.ts
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 356cb5ea6b
feat(api): create review endpoints
create endpoints for adding+getting a single chapter's reviews
2023-10-02 21:43:24 -04:00

12 lines
344 B
TypeScript

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