fix: add automatic draft compilation fallback in loader and explicit API error logging

This commit is contained in:
Daniel S
2026-08-10 00:16:41 +02:00
parent db2f607e5a
commit 4b7f3f554b
7 changed files with 63 additions and 2 deletions

View File

@@ -52,9 +52,43 @@
"title": "Bereit für Ihr Projekt?",
"subtitle": "Schreiben Sie uns direkt. Wir antworten innerhalb von 24 Stunden persönlich."
}
},
{
"id": "sec_bentogrid_1786313652833",
"type": "BentoGrid",
"settings": {
"sectionTitle": "Unsere Highlights",
"sectionSubtitle": "Modernste Features im Überblick"
}
},
{
"id": "sec_herosection_1786313653735",
"type": "HeroSection",
"settings": {
"title": "Neue Überschrift",
"subtitle": "Beschreibungstext hier eingeben.",
"ctaPrimaryText": "Jetzt anfragen",
"ctaPrimaryLink": "#contact"
}
},
{
"id": "sec_contactsection_1786313654351",
"type": "ContactSection",
"settings": {
"title": "Kontaktieren Sie uns",
"subtitle": "Wir antworten innerhalb von 24 Stunden."
}
},
{
"id": "sec_bentogrid_1786313698683",
"type": "BentoGrid",
"settings": {
"sectionTitle": "Unsere Highlights",
"sectionSubtitle": "Modernste Features im Überblick"
}
}
]
}
],
"updated_at": "2026-08-09T22:08:57.203Z"
"updated_at": "2026-08-09T22:16:29.073Z"
}

Binary file not shown.

View File

@@ -53,6 +53,7 @@ export const POST: APIRoute = async ({ request }) => {
return new Response(JSON.stringify({ success: true, section_id: secId }), { status: 201 });
} catch (error) {
console.error('[API /api/editor/add-section] Exception:', error);
return new Response(JSON.stringify({ error: 'Fehler beim Hinzufügen der Sektion' }), { status: 500 });
}
};

View File

@@ -20,6 +20,7 @@ export const POST: APIRoute = async ({ request }) => {
return new Response(JSON.stringify({ success: true, message: 'Sektion gelöscht' }), { status: 200 });
} catch (error) {
console.error('[API /api/editor/delete-section] Exception:', error);
return new Response(JSON.stringify({ error: 'Fehler beim Löschen der Sektion' }), { status: 500 });
}
};

View File

@@ -50,6 +50,7 @@ export const POST: APIRoute = async ({ request }) => {
return new Response(JSON.stringify({ success: true, settings: { ...updatedDraft, ...updatedStyles } }), { status: 200 });
} catch (error) {
console.error('[API /api/editor/update-section-settings] Exception:', error);
return new Response(JSON.stringify({ error: 'Fehler beim Aktualisieren der Sektions-Einstellungen' }), { status: 500 });
}
};

View File

@@ -28,6 +28,7 @@ export const POST: APIRoute = async ({ request }) => {
{ status: 200 }
);
} catch (error) {
console.error('[API /api/editor/update-section] Exception:', error);
return new Response(JSON.stringify({ error: 'Fehler beim Aktualisieren der Sektionen' }), { status: 500 });
}
};

View File

@@ -1,6 +1,7 @@
import fs from 'fs';
import path from 'path';
import { detectDeviceType } from './deviceDetect';
import { getDb } from '../db/index';
export interface UIComponent {
id: string; // Eindeutige ID (z.B. uuid / timestamp)
slotId: string; // Platz-ID (z.B. 'hero-badge-slot', 'hero-actions-slot', 'bento-slot-1')
@@ -283,7 +284,29 @@ export function loadWaasConfigs(userAgent: string = '', isDraft: boolean = false
const genericSitePath = path.join(dataDir, 'site.config.json');
let sitePath = genericSitePath;
if (isDraft && fs.existsSync(draftSitePath)) {
if (isDraft) {
if (!fs.existsSync(draftSitePath)) {
try {
const db = getDb();
const settingsRow = db.prepare('SELECT value_json FROM site_settings WHERE key = ?').get('site_config') as { value_json: string } | undefined;
const baseConfig = settingsRow ? JSON.parse(settingsRow.value_json) : {};
const pagesRows = db.prepare('SELECT * FROM pages ORDER BY created_at ASC').all() as any[];
const pages = pagesRows.map((page) => {
const sectionsRows = db.prepare('SELECT * FROM page_sections WHERE page_id = ? ORDER BY order_index ASC').all(page.id) as any[];
const sections = sectionsRows.map((sec) => ({
id: sec.id,
type: sec.section_type,
settings: { ...JSON.parse(sec.content_draft_json || '{}'), ...JSON.parse(sec.styles_json || '{}') }
}));
return { id: page.id, slug: page.slug, title: page.title, is_published: page.status === 'published', sections };
});
const fullDraftConfig = { ...baseConfig, pages, updated_at: new Date().toISOString() };
fs.mkdirSync(dataDir, { recursive: true });
fs.writeFileSync(draftSitePath, JSON.stringify(fullDraftConfig, null, 2), 'utf-8');
} catch (e) {
console.warn('[WaaS ConfigLoader] Fallback draft compilation warning:', e);
}
}
sitePath = draftSitePath;
} else if (fs.existsSync(deviceSitePath)) {
sitePath = deviceSitePath;