diff --git a/server/services/featureOrder.js b/server/services/featureOrder.js index 9f70276..36f8b9b 100644 --- a/server/services/featureOrder.js +++ b/server/services/featureOrder.js @@ -1,8 +1,8 @@ import { config } from '../config.js' -import { getDocument } from './appwriteAdmin.js' import { aboMemo } from './aboStatus.js' import { oeffentlicheAnsicht } from './featureRegistry.js' -import { ladeEinstellung } from './termine/kontext.js' +import { istObjekt } from './termine/ablauf.js' +import { holeOderNull, ladeEinstellung } from './termine/kontext.js' // Bausteine der Bestell-Vorpruefungen (POST /api/funktionen/:key/checkout, Task B6): Zustimmung, Abo-Hinweistexte, // Entwurf des Terminplaners. Die Route in routes/funktionen.js legt die Reihenfolge fest; jede Stufe hier ist @@ -32,7 +32,6 @@ const FASSUNG_VERALTET = 'Die Erklärungen wurden inzwischen geändert. Bitte li const MAX_HAKEN = 50 const fehlt = () => bestellFehler(400, ZUSTIMMUNG_FEHLT, 'zustimmung_fehlt') -const istObjekt = (wert) => wert !== null && typeof wert === 'object' && !Array.isArray(wert) const hatWert = (wert) => wert !== undefined && wert !== null /** @@ -92,18 +91,6 @@ export function aboMeldung(feature, grund) { return text(feature?.mails?.formen?.akk || 'diese Funktion') } -/** 404 "Dokument fehlt" (nicht: Collection oder Datenbank fehlt). */ -const dokumentFehlt = (err) => err?.status === 404 && err.type !== 'collection_not_found' && err.type !== 'database_not_found' - -async function holeOderNull(collectionId, id) { - try { - return await getDocument(collectionId, id) - } catch (err) { - if (dokumentFehlt(err)) return null - throw err - } -} - // Fragebogen aus termineConfig.fragebogen (JSON-Text): nur ein Objekt zaehlt, fehlend oder kaputt ist null function liesFragebogen(text) { if (typeof text !== 'string' || text === '') return null diff --git a/server/services/termine/kontext.js b/server/services/termine/kontext.js index 06d9256..fca8f08 100644 --- a/server/services/termine/kontext.js +++ b/server/services/termine/kontext.js @@ -42,7 +42,8 @@ const istObjekt = (wert) => wert !== null && typeof wert === 'object' && !Array. /** 404 "Dokument fehlt" (nicht: Collection oder Datenbank fehlt). */ const dokumentFehlt = (err) => err?.status === 404 && err.type !== 'collection_not_found' && err.type !== 'database_not_found' -async function holeOderNull(collectionId, id) { +/** Dokument lesen; fehlt es (404 "Dokument fehlt"), ist das Ergebnis null. Fehlt Collection oder Datenbank, wird der Fehler weitergereicht. */ +export async function holeOderNull(collectionId, id) { try { return await getDocument(collectionId, id) } catch (err) {