From fde6f683d6dc42142b1603ef6caa94f262d02e2d Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 20 Nov 2024 14:45:16 -0500 Subject: [PATCH] feat: push ama questions to sanity --- server/api/question.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/api/question.ts b/server/api/question.ts index 9ab5bd6e..70b0fc65 100644 --- a/server/api/question.ts +++ b/server/api/question.ts @@ -1,10 +1,14 @@ export default defineEventHandler(async event => { if (event.method === 'OPTIONS') return null + const sanity = useSanity() assertMethod(event, 'POST') const { question } = await readBody(event) if (!question) throw createError({ statusCode: 422 }) + + event.waitUntil(sanity.client.create({ _type: 'ama', content: question }).catch(console.error)) event.waitUntil(createTypefullyDraft(event, question).catch(console.error)) + await sendEmail(event, 'Anonymous question', question) return null }) -- knotmirror 0.0.1