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
36 lines
934 B
TypeScript
36 lines
934 B
TypeScript
/**
|
|
* POST /api/instances/:id/disconnect
|
|
* Disconnect an instance
|
|
*/
|
|
import { query } from '../../../utils/database'
|
|
import { baileysManager } from '../../../services/baileys/manager'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const username = getHeader(event, 'x-authentik-username')
|
|
if (!username) {
|
|
throw createError({ statusCode: 401, message: 'Unauthorized' })
|
|
}
|
|
|
|
const id = getRouterParam(event, 'id')
|
|
|
|
// Check if instance exists
|
|
const result = await query<{ id: string }>(
|
|
'SELECT id FROM instances WHERE id = $1',
|
|
[id]
|
|
)
|
|
|
|
if (result.rows.length === 0) {
|
|
throw createError({ statusCode: 404, message: 'Instance not found' })
|
|
}
|
|
|
|
try {
|
|
await baileysManager.disconnect(id!)
|
|
return { success: true, status: 'disconnected' }
|
|
} catch (error) {
|
|
throw createError({
|
|
statusCode: 500,
|
|
message: `Failed to disconnect: ${(error as Error).message}`
|
|
})
|
|
}
|
|
})
|