import { httpClient } from '~~/server/lib/triplit'; import { cancelPendingRename } from '~~/server/utils/renames'; import { assert } from '~~/utils/assert'; export default defineEventHandler(async (event) => { await protectRoute(event); const { renameId } = event.context.params!; assert(renameId); const [success, pendingRename] = cancelPendingRename(renameId); if (success) { const topic = await httpClient.fetchOne(httpClient.query('topics').Where('id', '=', pendingRename!.topicId)); if (topic !== null && topic.renaming) { await httpClient.update('topics', topic.id, { renaming: false, }); } return { success: true, }; } return { success: false, }; });