All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- HomeMessages : type pill (Réaction/Question/Suggestion/Retour) + sélecteur dans le formulaire (sans Réaction) - HomeMessages : white-space: pre-line sur les messages - Page /messages : type pill + white-space: pre-line (idem home) - Admin : badge type coloré + sélecteur d'édition + formulaire réponse - API : type et reply dans PUT ; readDataYaml/writeDataYaml (data/ volume Docker) - main.css : overrides light mode text-white/55, /75, /90 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
29 lines
808 B
TypeScript
29 lines
808 B
TypeScript
const EMPTY = { messages: [] as any[] }
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const body = await readBody<{ author: string; email?: string; text: string; type?: string }>(event)
|
|
|
|
if (!body.text?.trim()) {
|
|
throw createError({ statusCode: 400, statusMessage: 'Message requis' })
|
|
}
|
|
|
|
const data = await readDataYaml<{ messages: any[] }>('messages.yml', EMPTY)
|
|
|
|
const maxId = data.messages.reduce((max, m) => Math.max(max, m.id || 0), 0)
|
|
|
|
data.messages.push({
|
|
id: maxId + 1,
|
|
author: body.author?.trim() || 'Anonyme',
|
|
email: body.email?.trim() || '',
|
|
text: body.text.trim(),
|
|
type: body.type || 'reaction',
|
|
published: false,
|
|
createdAt: new Date().toISOString(),
|
|
reply: null,
|
|
})
|
|
|
|
await writeDataYaml('messages.yml', data)
|
|
|
|
return { ok: true }
|
|
})
|