This repository has been archived on 2026-02-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
BreakPilot Dev 19855efacc
Some checks failed
Tests / Go Tests (push) Has been cancelled
Tests / Python Tests (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / Go Lint (push) Has been cancelled
Tests / Python Lint (push) Has been cancelled
Tests / Security Scan (push) Has been cancelled
Tests / All Checks Passed (push) Has been cancelled
Security Scanning / Secret Scanning (push) Has been cancelled
Security Scanning / Dependency Vulnerability Scan (push) Has been cancelled
Security Scanning / Go Security Scan (push) Has been cancelled
Security Scanning / Python Security Scan (push) Has been cancelled
Security Scanning / Node.js Security Scan (push) Has been cancelled
Security Scanning / Docker Image Security (push) Has been cancelled
Security Scanning / Security Summary (push) Has been cancelled
CI/CD Pipeline / Go Tests (push) Has been cancelled
CI/CD Pipeline / Python Tests (push) Has been cancelled
CI/CD Pipeline / Website Tests (push) Has been cancelled
CI/CD Pipeline / Linting (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Docker Build & Push (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / CI Summary (push) Has been cancelled
ci/woodpecker/manual/build-ci-image Pipeline was successful
ci/woodpecker/manual/main Pipeline failed
feat: BreakPilot PWA - Full codebase (clean push without large binaries)
All services: admin-v2, studio-v2, website, ai-compliance-sdk,
consent-service, klausur-service, voice-service, and infrastructure.
Large PDFs and compiled binaries excluded via .gitignore.
2026-02-11 13:25:58 +01:00

116 lines
2.9 KiB
TypeScript

import { NextRequest, NextResponse } from 'next/server'
import { writeFile, readFile, mkdir } from 'fs/promises'
import { existsSync } from 'fs'
import path from 'path'
// Speicherort fuer Uploads
const UPLOADS_DIR = '/tmp/breakpilot-uploads'
const METADATA_FILE = path.join(UPLOADS_DIR, 'metadata.json')
interface UploadedFile {
id: string
sessionId: string
name: string
type: string
size: number
uploadedAt: string
dataUrl: string // Base64 data URL
}
// Stelle sicher, dass das Upload-Verzeichnis existiert
async function ensureUploadsDir() {
if (!existsSync(UPLOADS_DIR)) {
await mkdir(UPLOADS_DIR, { recursive: true })
}
}
// Lade Metadaten
async function loadMetadata(): Promise<UploadedFile[]> {
try {
await ensureUploadsDir()
if (existsSync(METADATA_FILE)) {
const data = await readFile(METADATA_FILE, 'utf-8')
return JSON.parse(data)
}
} catch (error) {
console.error('Error loading metadata:', error)
}
return []
}
// Speichere Metadaten
async function saveMetadata(uploads: UploadedFile[]) {
await ensureUploadsDir()
await writeFile(METADATA_FILE, JSON.stringify(uploads, null, 2))
}
// GET: Liste alle Uploads fuer eine Session
export async function GET(request: NextRequest) {
const sessionId = request.nextUrl.searchParams.get('sessionId')
const uploads = await loadMetadata()
if (sessionId) {
const filtered = uploads.filter(u => u.sessionId === sessionId)
return NextResponse.json({ uploads: filtered })
}
// Alle Uploads (fuer Dashboard)
return NextResponse.json({ uploads })
}
// POST: Neuen Upload hinzufuegen
export async function POST(request: NextRequest) {
try {
const body = await request.json()
const { sessionId, name, type, size, dataUrl } = body
if (!sessionId || !name || !dataUrl) {
return NextResponse.json(
{ error: 'Missing required fields' },
{ status: 400 }
)
}
const upload: UploadedFile = {
id: `upload-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
sessionId,
name,
type: type || 'application/octet-stream',
size: size || 0,
uploadedAt: new Date().toISOString(),
dataUrl
}
const uploads = await loadMetadata()
uploads.push(upload)
await saveMetadata(uploads)
return NextResponse.json({ success: true, upload })
} catch (error) {
console.error('Upload error:', error)
return NextResponse.json(
{ error: 'Upload failed' },
{ status: 500 }
)
}
}
// DELETE: Upload loeschen
export async function DELETE(request: NextRequest) {
const id = request.nextUrl.searchParams.get('id')
if (!id) {
return NextResponse.json(
{ error: 'Missing upload id' },
{ status: 400 }
)
}
const uploads = await loadMetadata()
const filtered = uploads.filter(u => u.id !== id)
await saveMetadata(filtered)
return NextResponse.json({ success: true })
}