Some checks failed
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) Failing after 33s
CI / test-python-backend-compliance (push) Successful in 34s
CI / test-python-document-crawler (push) Successful in 23s
CI / test-python-dsms-gateway (push) Successful in 19s
Jeder Tenant kann jetzt mehrere Compliance-Projekte anlegen (z.B. verschiedene Produkte, Tochterunternehmen). CompanyProfile ist pro Projekt kopierbar und danach unabhaengig editierbar. Multi-Tab-Support via separater BroadcastChannel und localStorage Keys pro Projekt. - Migration 039: compliance_projects Tabelle, sdk_states.project_id - Backend: FastAPI CRUD-Routes fuer Projekte mit Tenant-Isolation - Frontend: ProjectSelector UI, SDKProvider mit projectId, URL ?project= - State API: UPSERT auf (tenant_id, project_id) mit Abwaertskompatibilitaet - Tests: pytest fuer Model-Validierung, Row-Konvertierung, Tenant-Isolation - Docs: MKDocs Seite, CLAUDE.md, Backend README Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
76 lines
2.1 KiB
TypeScript
76 lines
2.1 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server'
|
|
|
|
const BACKEND_URL = process.env.BACKEND_URL || 'http://backend-compliance:8002'
|
|
|
|
/**
|
|
* Proxy: GET /api/sdk/v1/projects → Backend GET /api/v1/projects
|
|
*/
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
const { searchParams } = new URL(request.url)
|
|
const tenantId = searchParams.get('tenant_id') || request.headers.get('X-Tenant-ID') || ''
|
|
const includeArchived = searchParams.get('include_archived') || 'false'
|
|
|
|
const response = await fetch(
|
|
`${BACKEND_URL}/api/v1/projects?tenant_id=${encodeURIComponent(tenantId)}&include_archived=${includeArchived}`,
|
|
{
|
|
headers: { 'X-Tenant-ID': tenantId },
|
|
}
|
|
)
|
|
|
|
if (!response.ok) {
|
|
const errorText = await response.text()
|
|
return NextResponse.json(
|
|
{ error: 'Backend error', details: errorText },
|
|
{ status: response.status }
|
|
)
|
|
}
|
|
|
|
return NextResponse.json(await response.json())
|
|
} catch (error) {
|
|
console.error('Failed to list projects:', error)
|
|
return NextResponse.json(
|
|
{ error: 'Failed to connect to backend' },
|
|
{ status: 503 }
|
|
)
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Proxy: POST /api/sdk/v1/projects → Backend POST /api/v1/projects
|
|
*/
|
|
export async function POST(request: NextRequest) {
|
|
try {
|
|
const body = await request.json()
|
|
const tenantId = body.tenant_id || request.headers.get('X-Tenant-ID') || ''
|
|
|
|
const response = await fetch(
|
|
`${BACKEND_URL}/api/v1/projects?tenant_id=${encodeURIComponent(tenantId)}`,
|
|
{
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'X-Tenant-ID': tenantId,
|
|
},
|
|
body: JSON.stringify(body),
|
|
}
|
|
)
|
|
|
|
if (!response.ok) {
|
|
const errorText = await response.text()
|
|
return NextResponse.json(
|
|
{ error: 'Backend error', details: errorText },
|
|
{ status: response.status }
|
|
)
|
|
}
|
|
|
|
return NextResponse.json(await response.json(), { status: 201 })
|
|
} catch (error) {
|
|
console.error('Failed to create project:', error)
|
|
return NextResponse.json(
|
|
{ error: 'Failed to connect to backend' },
|
|
{ status: 503 }
|
|
)
|
|
}
|
|
}
|