2023-12-20 17:23:31 -05:00
|
|
|
import { chapterTransformer } from "@server/dbHelpers";
|
|
|
|
import { storyQuerier } from "@server/dbHelpers";
|
2023-12-29 16:32:32 -05:00
|
|
|
import { storyCheck } from "@server/middlewareButNotReally";
|
2023-10-02 15:46:56 -04:00
|
|
|
|
|
|
|
export default eventHandler(async (ev) => {
|
|
|
|
const story = await storyQuerier(ev);
|
2023-12-01 17:54:30 -05:00
|
|
|
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);
|
|
|
|
}
|
2023-12-01 17:54:30 -05:00
|
|
|
return await chapterTransformer(story, ev, bi - 1);
|
2023-10-02 15:46:56 -04:00
|
|
|
});
|