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

14 lines
467 B
TypeScript
Raw Normal View History

import { chapterTransformer } from "@server/dbHelpers";
import { storyQuerier } from "@server/dbHelpers";
import { storyCheck } from "@server/middlewareButNotReally";
2023-10-02 15:46:56 -04:00
export default eventHandler(async (ev) => {
const story = await storyQuerier(ev);
const bi = parseInt(getRouterParam(ev, "chapter")!);
const chres = await storyCheck(ev, story, bi - 1);
2023-10-02 15:46:56 -04:00
if (chres != null) {
throw createError(chres);
}
return await chapterTransformer(story, ev, bi - 1);
2023-10-02 15:46:56 -04:00
});