Analyse: Freischalten, Abschalten, Abo-Pruefung

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Sonnet 5.5 committed 2026-10-01 10:10:39 +00:00
1 parent 9e66f55c2c
commit f0eee196ed
10 files changed
+540 -32

No files matched your search

+1 -25
View File
@@ -6,9 +6,8 @@ import { requireAppwriteStaff } from '../../middleware/appwriteStaff.js'
import { envKey, encryptEnv, decryptEnv, envNames, validateEnvChange } from '../../services/previewEnv.js'
import { listRunLogs, readRunLog, isRunFile } from '../../services/previewLogs.js'
import * as runnerClient from '../../services/previewRunnerClient.js'
import { runDeploy, fetchPreviewConfig } from '../../services/previewDeploy.js'
import { triggerRebuild, previewBranchOf } from '../../services/previewRebuild.js'
import { withLocks } from '../../services/keyedLock.js'
import { getRepoInfo } from '../../services/giteaAdmin.js'
import { repoHasDevScript } from '../../services/previewDevScript.js'
const router = Router()
@@ -64,29 +63,6 @@ async function view(doc) {
}
}
async function previewBranchOf(doc) {
return doc.previewBranch || (await getRepoInfo(doc.repoFullName).catch(() => null))?.defaultBranch || 'main'
}
// Neubau anstossen (wie beim Bearbeiten/Reaktivieren eines Projekts)
async function triggerRebuild(doc) {
const repo = doc.repoFullName
const branch = await previewBranchOf(doc)
const found = await fetchPreviewConfig(repo, branch).catch(() => null)
const cfg = {
enabled: true,
type: 'static',
displayName: doc.projectName,
...(found || {}),
branch,
subdomain: doc.subdomain,
}
const result = await runDeploy(repo, branch, cfg, { project: doc })
// runDeploy meldet Runner-Fehler im Ergebnis; Schutzschalter (503) an WOMS durchreichen
if (result?.error && /Server ausgelastet/.test(result.error)) throw fail(503, BUSY)
return result
}
const wrap = (fn) => async (req, res) => {
try {
await fn(req, res)