feat: basePath-Konfiguration von .env in config.json verschoben
basePath wird jetzt in config.json gepflegt statt als NEXT_PUBLIC_BASE_PATH in .env.* Alle relevanten Code-Stellen lesen basePath dynamisch aus config.json Dokumentation und Beispiele in Markdown-Dateien entsprechend angepasst Erhöhte Flexibilität für Deployments ohne Rebuild
This commit is contained in:
@@ -1,7 +1,17 @@
|
||||
// /services/webservice/fetchGisLinesStatusService.js
|
||||
let __configCache;
|
||||
async function getConfig() {
|
||||
if (__configCache) return __configCache;
|
||||
const res = await fetch("/config.json");
|
||||
if (!res.ok) throw new Error("config.json konnte nicht geladen werden");
|
||||
__configCache = await res.json();
|
||||
return __configCache;
|
||||
}
|
||||
|
||||
export const fetchGisLinesStatusService = async () => {
|
||||
const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true";
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
|
||||
const config = await getConfig();
|
||||
const basePath = config.basePath || "";
|
||||
|
||||
if (useMocks) {
|
||||
const mockBasePath = "/api/mocks/webservice/gisLinesStatus";
|
||||
@@ -16,11 +26,9 @@ export const fetchGisLinesStatusService = async () => {
|
||||
}
|
||||
|
||||
const mockData = await response.json();
|
||||
|
||||
if (!Array.isArray(mockData.Statis)) {
|
||||
throw new Error("Ungültige Struktur: 'Status' fehlt im Mock");
|
||||
}
|
||||
|
||||
return mockData.Statis;
|
||||
} else {
|
||||
const baseUrl = `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx`;
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
let __configCache;
|
||||
async function getConfig() {
|
||||
if (__configCache) return __configCache;
|
||||
const res = await fetch("/config.json");
|
||||
if (!res.ok) throw new Error("config.json konnte nicht geladen werden");
|
||||
__configCache = await res.json();
|
||||
return __configCache;
|
||||
}
|
||||
|
||||
export const fetchGisStationsMeasurementsService = async () => {
|
||||
const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true";
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
|
||||
const config = await getConfig();
|
||||
const basePath = config.basePath || "";
|
||||
|
||||
if (useMocks) {
|
||||
const mockBasePath = "/api/mocks/webservice/gisStationsMeasurements";
|
||||
|
||||
@@ -5,9 +5,19 @@
|
||||
* @returns {Promise<Array>} Liste mit Points[]
|
||||
* @throws {Error} bei Fehler oder ungültiger Antwortstruktur
|
||||
*/
|
||||
let __configCache;
|
||||
async function getConfig() {
|
||||
if (__configCache) return __configCache;
|
||||
const res = await fetch("/config.json");
|
||||
if (!res.ok) throw new Error("config.json konnte nicht geladen werden");
|
||||
__configCache = await res.json();
|
||||
return __configCache;
|
||||
}
|
||||
|
||||
export const fetchGisStationsStaticDistrictService = async () => {
|
||||
const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true";
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
|
||||
const config = await getConfig();
|
||||
const basePath = config.basePath || "";
|
||||
|
||||
if (useMocks) {
|
||||
const mockBasePath = "/api/mocks/webservice/gisStationsStaticDistrict";
|
||||
|
||||
@@ -5,9 +5,19 @@
|
||||
* @returns {Promise<Array>} Liste mit Statis[]
|
||||
* @throws {Error} bei Fehler oder ungültiger Antwortstruktur
|
||||
*/
|
||||
let __configCache;
|
||||
async function getConfig() {
|
||||
if (__configCache) return __configCache;
|
||||
const res = await fetch("/config.json");
|
||||
if (!res.ok) throw new Error("config.json konnte nicht geladen werden");
|
||||
__configCache = await res.json();
|
||||
return __configCache;
|
||||
}
|
||||
|
||||
export const fetchGisStationsStatusDistrictService = async () => {
|
||||
const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true";
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
|
||||
const config = await getConfig();
|
||||
const basePath = config.basePath || "";
|
||||
|
||||
if (useMocks) {
|
||||
const mockBasePath = "/api/mocks/webservice/gisStationsStatusDistrict";
|
||||
|
||||
@@ -4,9 +4,19 @@
|
||||
* @returns {Promise<Array>} Liste mit Systems[]
|
||||
* @throws {Error} bei Fehler oder ungültiger Antwortstruktur
|
||||
*/
|
||||
let __configCache;
|
||||
async function getConfig() {
|
||||
if (__configCache) return __configCache;
|
||||
const res = await fetch("/config.json");
|
||||
if (!res.ok) throw new Error("config.json konnte nicht geladen werden");
|
||||
__configCache = await res.json();
|
||||
return __configCache;
|
||||
}
|
||||
|
||||
export const fetchGisSystemStaticService = async () => {
|
||||
const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true";
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
|
||||
const config = await getConfig();
|
||||
const basePath = config.basePath || "";
|
||||
|
||||
if (useMocks) {
|
||||
const mockBasePath = "/api/mocks/webservice/gisSystemStatic";
|
||||
|
||||
@@ -4,9 +4,19 @@
|
||||
* @returns {Promise<Array>} Rechte-Array
|
||||
* @throws {Error} bei Lade- oder Strukturfehler
|
||||
*/
|
||||
let __configCache;
|
||||
async function getConfig() {
|
||||
if (__configCache) return __configCache;
|
||||
const res = await fetch("/config.json");
|
||||
if (!res.ok) throw new Error("config.json konnte nicht geladen werden");
|
||||
__configCache = await res.json();
|
||||
return __configCache;
|
||||
}
|
||||
|
||||
export const fetchUserRightsService = async () => {
|
||||
const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true";
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
|
||||
const config = await getConfig();
|
||||
const basePath = config.basePath || "";
|
||||
|
||||
if (useMocks) {
|
||||
const mockBasePath = "/api/mocks/webservice/gisSystemStatic";
|
||||
|
||||
Reference in New Issue
Block a user