fix(api): update story editing route

properly await `replaceOrUpdateContent`
This commit is contained in:
parent 205b241e3b
commit 74722ddfd6
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

@ -9,13 +9,7 @@ import { countWords } from "@functions";
import { messages } from "@server/constants"; import { messages } from "@server/constants";
export default eventHandler(async (ev) => { export default eventHandler(async (ev) => {
let os: let os: (Document<unknown, {}, IStory> & IStory) | null = await storyQuerier(ev);
| (Document<unknown, {}, IStory> &
IStory &
Required<{
_id: number;
}>)
| null = await storyQuerier(ev);
isLoggedIn(ev); isLoggedIn(ev);
if (!canModify(ev, os)) { if (!canModify(ev, os)) {
throw createError({ throw createError({
@ -52,7 +46,7 @@ export default eventHandler(async (ev) => {
id: os.chapters[idx].id, id: os.chapters[idx].id,
posted: os.chapters[idx].posted, posted: os.chapters[idx].posted,
}); });
replaceOrUploadContent(os.chapters![idx].id, cont); await replaceOrUploadContent(os.chapters![idx].id, cont);
} }
update.chapters![update.chapters!.length - 1].words = countWords(cont); update.chapters![update.chapters!.length - 1].words = countWords(cont);
} }