Add Nextcloud and Azure test connection handlers

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-14 11:05:17 +00:00
parent f43c46e794
commit 8a4c4182ec

View file

@ -118,6 +118,27 @@ export async function integrationRoutes(app) {
})
await transporter.verify()
}
else if (req.params.slug === 'nextcloud') {
if (!creds.base_url || !creds.username || !creds.password) throw new Error('Nextcloud base URL, username and password are required')
const url = `${creds.base_url.replace(/\/$/, '')}/remote.php/dav/files/${encodeURIComponent(creds.username)}/`
const res = await fetch(url, {
method: 'PROPFIND',
headers: { Authorization: `Basic ${Buffer.from(`${creds.username}:${creds.password}`).toString('base64')}`, Depth: '0' },
signal: AbortSignal.timeout(8000),
})
if (res.status === 401) throw new Error('Invalid Nextcloud credentials')
if (!res.ok) throw new Error(`Nextcloud returned ${res.status}`)
}
else if (req.params.slug === 'azure') {
if (!creds.endpoint || !creds.api_key) throw new Error('Azure endpoint and API key are required')
const base = creds.endpoint.replace(/\/$/, '')
const res = await fetch(`${base}/documentintelligence/info?api-version=2024-11-30`, {
headers: { 'Ocp-Apim-Subscription-Key': creds.api_key },
signal: AbortSignal.timeout(8000),
})
if (res.status === 401 || res.status === 403) throw new Error('Invalid Azure API key')
if (!res.ok) throw new Error(`Azure returned ${res.status}`)
}
else return reply.status(400).send({ error: `No test available for ${req.params.slug}` })
return { ok: true }
} catch (e) {