f21ecf293b
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-school (push) Successful in 31s
CI / test-go-edu-search (push) Successful in 29s
CI / test-python-klausur (push) Failing after 2m36s
CI / test-python-agent-core (push) Successful in 20s
CI / test-nodejs-website (push) Successful in 22s
Phase 3 — initial UI for the timetable scheduler:
- app/stundenplan/page.tsx with tab navigation (Klassen / Lehrer /
Faecher / Raeume / Zeitraster / Stundentafel / Lehrauftraege /
Regeln) and a dev-mode JWT entry to authenticate against
school-service until full auth is wired up.
- app/stundenplan/_components/KlassenManager.tsx as the working
prototype for one entity (list / create / delete). Pattern can be
copied for the other 6 stammdaten + 15 constraint editors.
- lib/stundenplan/api.ts exposing typed clients for all 22 endpoints
(7 stammdaten + 15 constraint tables). Constraints use a factory
to keep the file tight.
- app/api/school/[...path]/route.ts proxies the browser through
Next.js to school-service so HTTPS studio-v2 can reach the plain
HTTP backend.
- Sidebar.tsx gains a Stundenplan entry with 26-language labels.
- docker-compose.yml exposes SCHOOL_SERVICE_URL to studio-v2 and
declares the school-service dependency.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
66 lines
2.2 KiB
TypeScript
66 lines
2.2 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server'
|
|
|
|
/**
|
|
* Proxy for the school-service (Go/Gin, port 8084). The browser cannot call
|
|
* the backend directly because studio-v2 is served over HTTPS and the backend
|
|
* is plain HTTP; this Next.js route bridges them server-side.
|
|
*/
|
|
|
|
const BACKEND_URL = process.env.SCHOOL_SERVICE_URL || 'http://school-service:8084'
|
|
|
|
async function proxyRequest(
|
|
request: NextRequest,
|
|
params: { path: string[] }
|
|
): Promise<NextResponse> {
|
|
const path = params.path.join('/')
|
|
const url = `${BACKEND_URL}/api/v1/school/${path}`
|
|
|
|
try {
|
|
const headers: HeadersInit = { 'Content-Type': 'application/json' }
|
|
const authHeader = request.headers.get('authorization')
|
|
if (authHeader) headers['Authorization'] = authHeader
|
|
|
|
const fetchOptions: RequestInit = {
|
|
method: request.method,
|
|
headers,
|
|
}
|
|
|
|
if (['POST', 'PUT', 'PATCH'].includes(request.method)) {
|
|
fetchOptions.body = await request.text()
|
|
}
|
|
|
|
const response = await fetch(url, fetchOptions)
|
|
const contentType = response.headers.get('content-type')
|
|
const data = contentType?.includes('application/json')
|
|
? await response.text()
|
|
: await response.arrayBuffer()
|
|
|
|
return new NextResponse(data, {
|
|
status: response.status,
|
|
headers: { 'Content-Type': contentType || 'application/json' },
|
|
})
|
|
} catch (error) {
|
|
console.error(`Failed to proxy ${request.method} ${url}:`, error)
|
|
return NextResponse.json(
|
|
{ error: 'school-service nicht erreichbar', details: error instanceof Error ? error.message : 'Unknown error' },
|
|
{ status: 502 },
|
|
)
|
|
}
|
|
}
|
|
|
|
export async function GET(request: NextRequest, context: { params: Promise<{ path: string[] }> }) {
|
|
return proxyRequest(request, await context.params)
|
|
}
|
|
|
|
export async function POST(request: NextRequest, context: { params: Promise<{ path: string[] }> }) {
|
|
return proxyRequest(request, await context.params)
|
|
}
|
|
|
|
export async function PUT(request: NextRequest, context: { params: Promise<{ path: string[] }> }) {
|
|
return proxyRequest(request, await context.params)
|
|
}
|
|
|
|
export async function DELETE(request: NextRequest, context: { params: Promise<{ path: string[] }> }) {
|
|
return proxyRequest(request, await context.params)
|
|
}
|