Files
CPLv4.0/services/fetchAllTDRReferenceChartData.ts
Ismail Ali 9e931eed0f refactor: last20Messages und digitale Eingänge auf API-gesteuerte Mock-Dateien umgestellt
- Start.js (last20Messages) als JS-Mock in /apiMockData/jsMockFiles gespeichert
- de.js (digitale Eingänge) in /apiMockData/SERVICE verlagert
- Beide werden über eigene API-Endpoints bzw. per Script-Tag aus Development-Verzeichnis geladen
- Kein Zugriff mehr über /public notwendig, Verhalten in DEV und PROD identisch
2025-04-15 07:20:17 +02:00

34 lines
806 B
TypeScript

// /services/fetchAllTDRReferenceChartData.ts
const getTDRReferenceBasePath = () => {
if (typeof window !== "undefined") {
const env = process.env.NEXT_PUBLIC_NODE_ENV;
return env === "development"
? "/apiMockData/tdr-reference-curves"
: "/CPL?/CPL/tdr-reference-curves";
}
return "";
};
export const fetchAllTDRReferenceChartData = async () => {
const maxSlots = 32;
const results = [];
const basePath = getTDRReferenceBasePath();
for (let i = 0; i < maxSlots; i++) {
try {
const response = await fetch(`${basePath}/slot${i}.json`);
if (!response.ok) {
results[i] = null;
continue;
}
const json = await response.json();
results[i] = json;
} catch (error) {
results[i] = null;
}
}
return results;
};