- backend/workspaces/backend/ → backend/ - backend/workspaces/frontend/ → frontend/ - backend/.devcontainer/ + .vscode/ → repo root (where VS Code expects them) - loose scripts/SQL files → scripts/ - replace nested git repo with single repo at project root - update docker-compose.yml build context and devcontainer.json path - add root .gitignore Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
38 lines
1011 B
TypeScript
38 lines
1011 B
TypeScript
import { error, redirect } from '@sveltejs/kit';
|
|
import { env } from '$env/dynamic/private';
|
|
|
|
export async function load({ params, fetch }) {
|
|
const { id } = params;
|
|
|
|
|
|
const baseUrl = env.API_INTERNAL_URL || 'http://localhost:8080';
|
|
|
|
try {
|
|
const res = await fetch(`${baseUrl}/api/documents/${id}`);
|
|
|
|
if (res.status === 404) {
|
|
throw error(404, 'Dokument nicht gefunden');
|
|
}
|
|
|
|
if (res.status === 401) {
|
|
throw redirect(302, '/login');
|
|
}
|
|
|
|
if (!res.ok) {
|
|
console.error(`Backend Fehler (${res.status}):`, res.statusText);
|
|
throw error(500, 'Fehler beim Laden des Dokuments');
|
|
}
|
|
|
|
const document = await res.json();
|
|
|
|
return {
|
|
document
|
|
};
|
|
} catch (e) {
|
|
// Fehlerbehandlung
|
|
if (e.status) throw e; // Redirects und HttpErrors durchlassen
|
|
console.error("Ladefehler:", e);
|
|
throw error(500, 'Verbindung zum Server fehlgeschlagen');
|
|
}
|
|
}
|