2023-10-02 15:44:55 -04:00
|
|
|
import queryStory from "~/lib/server/dbHelpers/storyQuerier";
|
|
|
|
import storyCheck from "~/lib/server/middlewareButNotReally/storyCheck";
|
|
|
|
export default eventHandler(async (ev) => {
|
|
|
|
const story = await queryStory(ev);
|
2023-12-06 21:59:34 -05:00
|
|
|
let chrs = await storyCheck(ev, story, 0);
|
2023-10-02 15:44:55 -04:00
|
|
|
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;
|
|
|
|
});
|