fix: enforce strict draft vs publish isolation on all editor API endpoints
All checks were successful
Production Build & Deploy / build-and-deploy (push) Successful in 46s
All checks were successful
Production Build & Deploy / build-and-deploy (push) Successful in 46s
This commit is contained in:
@@ -73,7 +73,6 @@ export const POST: APIRoute = async ({ request }) => {
|
|||||||
targetPage.sections.push(newSection);
|
targetPage.sections.push(newSection);
|
||||||
|
|
||||||
await fs.mkdir(DATA_DIR, { recursive: true });
|
await fs.mkdir(DATA_DIR, { recursive: true });
|
||||||
await fs.writeFile(livePath, JSON.stringify(config, null, 2), 'utf-8');
|
|
||||||
await fs.writeFile(draftPath, JSON.stringify(config, null, 2), 'utf-8');
|
await fs.writeFile(draftPath, JSON.stringify(config, null, 2), 'utf-8');
|
||||||
|
|
||||||
return new Response(JSON.stringify({ success: true, section: newSection }), { status: 201 });
|
return new Response(JSON.stringify({ success: true, section: newSection }), { status: 201 });
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ export const POST: APIRoute = async ({ request }) => {
|
|||||||
targetPage.sections = targetPage.sections.filter((sec: any) => sec.id !== section_id);
|
targetPage.sections = targetPage.sections.filter((sec: any) => sec.id !== section_id);
|
||||||
|
|
||||||
await fs.mkdir(DATA_DIR, { recursive: true });
|
await fs.mkdir(DATA_DIR, { recursive: true });
|
||||||
await fs.writeFile(livePath, JSON.stringify(config, null, 2), 'utf-8');
|
|
||||||
await fs.writeFile(draftPath, JSON.stringify(config, null, 2), 'utf-8');
|
await fs.writeFile(draftPath, JSON.stringify(config, null, 2), 'utf-8');
|
||||||
|
|
||||||
return new Response(JSON.stringify({ success: true, message: 'Sektion gelöscht' }), { status: 200 });
|
return new Response(JSON.stringify({ success: true, message: 'Sektion gelöscht' }), { status: 200 });
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ export const POST: APIRoute = async ({ request }) => {
|
|||||||
const updatedConfig = { ...baseConfig, ...draftBody, updated_at: new Date().toISOString() };
|
const updatedConfig = { ...baseConfig, ...draftBody, updated_at: new Date().toISOString() };
|
||||||
|
|
||||||
await fs.mkdir(DATA_DIR, { recursive: true });
|
await fs.mkdir(DATA_DIR, { recursive: true });
|
||||||
await fs.writeFile(livePath, JSON.stringify(updatedConfig, null, 2), 'utf-8');
|
|
||||||
await fs.writeFile(draftPath, JSON.stringify(updatedConfig, null, 2), 'utf-8');
|
await fs.writeFile(draftPath, JSON.stringify(updatedConfig, null, 2), 'utf-8');
|
||||||
|
|
||||||
return new Response(JSON.stringify({ success: true, message: 'Entwurf erfolgreich gespeichert' }), { status: 200 });
|
return new Response(JSON.stringify({ success: true, message: 'Entwurf erfolgreich gespeichert' }), { status: 200 });
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ export const POST: APIRoute = async ({ request }) => {
|
|||||||
targetSection.settings = { ...targetSection.settings, ...settings };
|
targetSection.settings = { ...targetSection.settings, ...settings };
|
||||||
|
|
||||||
await fs.mkdir(DATA_DIR, { recursive: true });
|
await fs.mkdir(DATA_DIR, { recursive: true });
|
||||||
await fs.writeFile(livePath, JSON.stringify(config, null, 2), 'utf-8');
|
|
||||||
await fs.writeFile(draftPath, JSON.stringify(config, null, 2), 'utf-8');
|
await fs.writeFile(draftPath, JSON.stringify(config, null, 2), 'utf-8');
|
||||||
|
|
||||||
return new Response(JSON.stringify({ success: true, settings: targetSection.settings }), { status: 200 });
|
return new Response(JSON.stringify({ success: true, settings: targetSection.settings }), { status: 200 });
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ export const POST: APIRoute = async ({ request }) => {
|
|||||||
|
|
||||||
// 3. Speichere ausschließlich in site.config.draft.json
|
// 3. Speichere ausschließlich in site.config.draft.json
|
||||||
await fs.mkdir(DATA_DIR, { recursive: true });
|
await fs.mkdir(DATA_DIR, { recursive: true });
|
||||||
await fs.writeFile(livePath, JSON.stringify(config, null, 2), 'utf-8');
|
|
||||||
await fs.writeFile(draftPath, JSON.stringify(config, null, 2), 'utf-8');
|
await fs.writeFile(draftPath, JSON.stringify(config, null, 2), 'utf-8');
|
||||||
|
|
||||||
return new Response(
|
return new Response(
|
||||||
|
|||||||
Reference in New Issue
Block a user