All checks were successful
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-ai-compliance (push) Successful in 48s
CI / test-python-backend-compliance (push) Successful in 35s
CI / test-python-document-crawler (push) Successful in 22s
CI / test-python-dsms-gateway (push) Successful in 20s
Phase A: 8 new IT-Security training modules (SEC-PWD, SEC-DESK, SEC-KIAI, SEC-BYOD, SEC-VIDEO, SEC-USB, SEC-INC, SEC-HOME) with CTM entries. Bulk content and quiz generation endpoints for all 28 modules. Phase B: Piper TTS service (Python/FastAPI) for local German speech synthesis. training_media table, TTSClient in Go backend, audio generation endpoints, AudioPlayer component in frontend. MinIO storage integration. Phase C: FFmpeg presentation video pipeline — LLM generates slide scripts, ImageMagick renders 1920x1080 slides, FFmpeg combines with audio to MP4. VideoPlayer and ScriptPreview components in frontend. New files: 15 created, 9 modified - compliance-tts-service/ (Dockerfile, main.py, tts_engine.py, storage.py, slide_renderer.py, video_generator.py) - migrations 014-016 (training engine, IT-security modules, media table) - training package (models, store, content_generator, media, handlers) - frontend (AudioPlayer, VideoPlayer, ScriptPreview, api, types, page) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
106 lines
2.7 KiB
TypeScript
106 lines
2.7 KiB
TypeScript
/**
|
|
* Training API Proxy - Catch-all route
|
|
* Proxies all /api/sdk/v1/training/* requests to ai-compliance-sdk backend
|
|
*/
|
|
|
|
import { NextRequest, NextResponse } from 'next/server'
|
|
|
|
const SDK_BACKEND_URL = process.env.SDK_API_URL || 'http://ai-compliance-sdk:8090'
|
|
|
|
async function proxyRequest(
|
|
request: NextRequest,
|
|
pathSegments: string[] | undefined,
|
|
method: string
|
|
) {
|
|
const pathStr = pathSegments?.join('/') || ''
|
|
const searchParams = request.nextUrl.searchParams.toString()
|
|
const basePath = `${SDK_BACKEND_URL}/sdk/v1/training`
|
|
const url = pathStr
|
|
? `${basePath}/${pathStr}${searchParams ? `?${searchParams}` : ''}`
|
|
: `${basePath}${searchParams ? `?${searchParams}` : ''}`
|
|
|
|
try {
|
|
const headers: HeadersInit = {
|
|
'Content-Type': 'application/json',
|
|
}
|
|
|
|
const headerNames = ['authorization', 'x-tenant-id', 'x-user-id', 'x-namespace-id', 'x-tenant-slug']
|
|
for (const name of headerNames) {
|
|
const value = request.headers.get(name)
|
|
if (value) {
|
|
headers[name] = value
|
|
}
|
|
}
|
|
|
|
const fetchOptions: RequestInit = {
|
|
method,
|
|
headers,
|
|
signal: AbortSignal.timeout(60000),
|
|
}
|
|
|
|
if (method === 'POST' || method === 'PUT') {
|
|
const body = await request.text()
|
|
if (body) {
|
|
fetchOptions.body = body
|
|
}
|
|
}
|
|
|
|
const response = await fetch(url, fetchOptions)
|
|
|
|
if (!response.ok) {
|
|
const errorText = await response.text()
|
|
let errorJson
|
|
try {
|
|
errorJson = JSON.parse(errorText)
|
|
} catch {
|
|
errorJson = { error: errorText }
|
|
}
|
|
return NextResponse.json(
|
|
{ error: `Backend Error: ${response.status}`, ...errorJson },
|
|
{ status: response.status }
|
|
)
|
|
}
|
|
|
|
const data = await response.json()
|
|
return NextResponse.json(data)
|
|
} catch (error) {
|
|
console.error('Training API proxy error:', error)
|
|
return NextResponse.json(
|
|
{ error: 'Verbindung zum SDK Backend fehlgeschlagen' },
|
|
{ status: 503 }
|
|
)
|
|
}
|
|
}
|
|
|
|
export async function GET(
|
|
request: NextRequest,
|
|
{ params }: { params: Promise<{ path?: string[] }> }
|
|
) {
|
|
const { path } = await params
|
|
return proxyRequest(request, path, 'GET')
|
|
}
|
|
|
|
export async function POST(
|
|
request: NextRequest,
|
|
{ params }: { params: Promise<{ path?: string[] }> }
|
|
) {
|
|
const { path } = await params
|
|
return proxyRequest(request, path, 'POST')
|
|
}
|
|
|
|
export async function PUT(
|
|
request: NextRequest,
|
|
{ params }: { params: Promise<{ path?: string[] }> }
|
|
) {
|
|
const { path } = await params
|
|
return proxyRequest(request, path, 'PUT')
|
|
}
|
|
|
|
export async function DELETE(
|
|
request: NextRequest,
|
|
{ params }: { params: Promise<{ path?: string[] }> }
|
|
) {
|
|
const { path } = await params
|
|
return proxyRequest(request, path, 'DELETE')
|
|
}
|