All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- GrateWizard : lancement URL simple (plus de popup embed), bloc dédié violet sur la home entre axes et événement - Messagerie : plus de champs obligatoires, plus de champ email séparé, hint email dans le message, remerciement onboarding - Page /numerique : 3 piliers (Logiciel libre, WoT, Cloud libre) avec projets associés, remplace les extraits livre hors-sujet - Admin : carte Messages ajoutée au dashboard - Safelist icônes complétée Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
25 lines
671 B
TypeScript
25 lines
671 B
TypeScript
export default defineEventHandler(async (event) => {
|
|
const body = await readBody<{ author: string; email?: string; text: string }>(event)
|
|
|
|
if (!body.text?.trim()) {
|
|
throw createError({ statusCode: 400, statusMessage: 'Message requis' })
|
|
}
|
|
|
|
const data = await readYaml<{ messages: any[] }>('messages.yml')
|
|
|
|
const maxId = data.messages.reduce((max, m) => Math.max(max, m.id || 0), 0)
|
|
|
|
data.messages.push({
|
|
id: maxId + 1,
|
|
author: body.author.trim(),
|
|
email: body.email?.trim() || '',
|
|
text: body.text.trim(),
|
|
published: false,
|
|
createdAt: new Date().toISOString(),
|
|
})
|
|
|
|
await writeYaml('messages.yml', data)
|
|
|
|
return { ok: true }
|
|
})
|