feat: WhatsApp Nucleo con Nuxt 4 + Baileys v7
Some checks failed
Build and Deploy / build-and-deploy (push) Failing after 6m46s
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:
42
server/api/instances/index.get.ts
Normal file
42
server/api/instances/index.get.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* GET /api/instances
|
||||
* List all instances
|
||||
*/
|
||||
import { query } from '../../utils/database'
|
||||
import { baileysManager } from '../../services/baileys/manager'
|
||||
|
||||
interface InstanceRow {
|
||||
id: string
|
||||
name: string
|
||||
phone_number: string | null
|
||||
status: string
|
||||
last_connected_at: Date | null
|
||||
created_at: Date
|
||||
}
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
// Check auth
|
||||
const username = getHeader(event, 'x-authentik-username')
|
||||
if (!username) {
|
||||
throw createError({ statusCode: 401, message: 'Unauthorized' })
|
||||
}
|
||||
|
||||
const result = await query<InstanceRow>(
|
||||
`SELECT id, name, phone_number, status, last_connected_at, created_at
|
||||
FROM instances
|
||||
ORDER BY created_at DESC`
|
||||
)
|
||||
|
||||
// Enrich with live status from manager
|
||||
return result.rows.map(row => {
|
||||
const liveStatus = baileysManager.getStatus(row.id)
|
||||
return {
|
||||
id: row.id,
|
||||
name: row.name,
|
||||
phoneNumber: row.phone_number,
|
||||
status: liveStatus?.status || row.status,
|
||||
lastConnectedAt: row.last_connected_at,
|
||||
createdAt: row.created_at
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user