Add Nextcloud and Azure test connection handlers
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f43c46e794
commit
8a4c4182ec
1 changed files with 21 additions and 0 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue