Preview: Builds ueber den Runner
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
40a8aad3f9
commit
4258b5b9f1
7 files changed
+526
-5
No files matched your search
@@ -0,0 +1,38 @@
|
||||
// HTTP-Client fuer den Preview-Runner (Bearer-Token, JSON)
|
||||
import { config } from '../config.js'
|
||||
|
||||
const TIMEOUT_MS = 15_000
|
||||
|
||||
async function call(method, path, body) {
|
||||
const { url, token } = config.previewRunner
|
||||
let response
|
||||
try {
|
||||
response = await fetch(`${String(url).replace(/\/$/, '')}${path}`, {
|
||||
method,
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
...(body !== undefined ? { 'Content-Type': 'application/json' } : {}),
|
||||
},
|
||||
body: body !== undefined ? JSON.stringify(body) : undefined,
|
||||
signal: AbortSignal.timeout(TIMEOUT_MS),
|
||||
})
|
||||
} catch (err) {
|
||||
throw new Error(`Preview-Runner nicht erreichbar: ${err.message}`)
|
||||
}
|
||||
const text = await response.text()
|
||||
let data = null
|
||||
try { data = text ? JSON.parse(text) : null } catch { data = { error: text } }
|
||||
if (!response.ok) {
|
||||
const error = new Error(data?.error || `Preview-Runner ${response.status}`)
|
||||
error.status = response.status
|
||||
throw error
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
export const submitBuild = (job) => call('POST', '/jobs/build', job)
|
||||
export const getRun = (runId) => call('GET', `/jobs/${encodeURIComponent(runId)}`)
|
||||
// Dev-Auftrag beim Runner hinterlegen (startet nicht, R12)
|
||||
export const startDev = (sub, job) => call('PUT', `/dev/${encodeURIComponent(sub)}`, job)
|
||||
export const stopDev = (sub) => call('POST', `/dev/${encodeURIComponent(sub)}/stop`, {})
|
||||
export const status = () => call('GET', '/status')
|
||||
Reference in new issue
Block a user