import chapterTransformer from "~/lib/server/dbHelpers/chapterTransformer";
import storyQuerier from "~/lib/server/dbHelpers/storyQuerier";
import storyCheck from "~/lib/server/middlewareButNotReally/storyCheck";

export default eventHandler(async (ev) => {
	const story = await storyQuerier(ev);
	const chres = await storyCheck(ev, story);
	if (chres != null) {
		throw createError(chres);
	}
	return await chapterTransformer(story, ev);
});
