From d5de2499ab4cc4650ae28d95fa86fdf0b38895f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Fri, 1 Dec 2023 17:57:17 -0500 Subject: [PATCH] refactor(server/utils): make the chapter index parameter in the chapterTransformer function mandatory --- lib/server/dbHelpers/chapterTransformer.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/server/dbHelpers/chapterTransformer.ts b/lib/server/dbHelpers/chapterTransformer.ts index 2b8e88c..722e89a 100644 --- a/lib/server/dbHelpers/chapterTransformer.ts +++ b/lib/server/dbHelpers/chapterTransformer.ts @@ -5,12 +5,13 @@ import { stringifyStream } from "~/lib/functions"; import { IStory } from "~/models/stories"; import { IChapter } from "~/models/stories/chapter"; import getBucket from "../storyHelpers/getBucket"; +import { SingleChapterResult } from "~/lib/client/types/slightlyDifferentStory"; export default async function ( story: Document & IStory, event: H3Event, - cindex?: number, -) { + cindex: number, +): Promise { const finObj: any = story.toObject(); const cloned: any & { chapters: IChapter[] } = { ...finObj }; delete finObj.chapters; @@ -30,5 +31,6 @@ export default async function ( .replace(/

<\/p>/gm, ""), }; finObj.totalChapters = story.chapters.length; + finObj.chapterNames = story.chapters.map((a) => a.title); return finObj; }