feat: WhatsApp Nucleo con Nuxt 4 + Baileys v7
Some checks failed
Build and Deploy / build-and-deploy (push) Failing after 6m46s

Reemplazo completo de Evolution API por implementación directa con Baileys.

Características:
- Dashboard completo con Nuxt UI v4
- Soporte para múltiples instancias de WhatsApp
- Conexión via QR code o pairing code
- Persistencia de mensajes en PostgreSQL
- API REST para integraciones externas
- Webhooks con firma HMAC
- SSE para actualizaciones en tiempo real
- Autenticación con Authentik
This commit is contained in:
2025-12-02 17:54:31 -06:00
parent 327118440b
commit faedec47d7
62 changed files with 4489 additions and 92 deletions

View File

@@ -0,0 +1,54 @@
/**
* POST /api/webhooks
* Create a webhook
*/
import { query } from '../../utils/database'
interface CreateWebhookBody {
name: string
url: string
secret?: string
events: string[]
instanceId?: string | null
}
export default defineEventHandler(async (event) => {
const username = getHeader(event, 'x-authentik-username')
if (!username) {
throw createError({ statusCode: 401, message: 'Unauthorized' })
}
const body = await readBody<CreateWebhookBody>(event)
if (!body.name?.trim()) {
throw createError({ statusCode: 400, message: 'Name is required' })
}
if (!body.url?.trim()) {
throw createError({ statusCode: 400, message: 'URL is required' })
}
if (!body.events?.length) {
throw createError({ statusCode: 400, message: 'At least one event is required' })
}
const result = await query<{ id: string }>(
`INSERT INTO webhooks (name, url, secret, events, instance_id, created_by)
VALUES ($1, $2, $3, $4, $5, $6)
RETURNING id`,
[
body.name.trim(),
body.url.trim(),
body.secret || null,
body.events,
body.instanceId || null,
username
]
)
return {
id: result.rows[0].id,
name: body.name,
url: body.url,
events: body.events,
instanceId: body.instanceId || null
}
})