/* Espe | Ein schlichtes Werkzeug zur Mitglieder-Verwaltung | Frontend Copyright (C) 2024 Christian Fraß This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ namespace _espe.conf { /** */ export type type_data = { backend : { scheme : string; host : string; port : int; path_base : string; }; settings : { title : string; test_mode : boolean; }; }; /** */ var _data : (null | type_data) = null; /** */ export async function load( ) : Promise { let data_raw; try { data_raw = lib_plankton.json.decode(await lib_plankton.file.read("conf.json")); } catch (error) { data_raw = {}; console.warn("could not read configuration file"); } _data = { "backend": ( (node_backend => ({ "scheme": (node_backend["scheme"] ?? "http"), "host": (node_backend["host"] ?? "localhost"), "port": (node_backend["port"] ?? 7979), "path_base": (node_backend["path_base"] ?? ""), })) (data_raw["backend"] ?? {}) ), "settings": ( (node_settings => ({ "title": (node_settings["title"] ?? "Espe"), "test_mode": (node_settings["test_mode"] ?? false), })) (data_raw["settings"] ?? {}) ), }; } /** */ export function get( ) : type_data { if (_data === null) { throw (new Error("conf not loaded yet")); } else { return _data; } } }