import { storyQuerier } from "@server/dbHelpers";
import { storyCheck } from "@server/middlewareButNotReally";
export default eventHandler(async (ev) => {
	const story = await storyQuerier(ev);
	let chrs = await storyCheck(ev, story, 0);
	if (chrs != null) {
		throw createError(chrs);
	}
	if (story.chapters.some((a) => a.loggedInOnly) && !ev.context.currentUser)
		throw createError({
			statusCode: 401,
			message: "Authentication required",
		});
	return story;
});
