2024-04-22 10:22:18 +02:00
|
|
|
namespace _espe.conf
|
2024-04-22 10:02:34 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
export type type_conf = {
|
|
|
|
port : int;
|
|
|
|
database_path : string;
|
|
|
|
email : {
|
|
|
|
mode : (
|
|
|
|
"regular"
|
|
|
|
|
|
|
|
|
"redirect"
|
|
|
|
|
|
|
|
|
"console"
|
|
|
|
|
|
|
|
|
"drop"
|
|
|
|
);
|
|
|
|
smtp_credentials : {
|
|
|
|
host : string;
|
|
|
|
port : int;
|
|
|
|
username : string;
|
|
|
|
password : string;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
session_lifetime : int;
|
|
|
|
session_drop_all_at_start : boolean;
|
|
|
|
email_domain : string;
|
|
|
|
email_numberbased_address_prefix : string;
|
|
|
|
verification_secret : string;
|
|
|
|
verbosity : (
|
|
|
|
"none"
|
|
|
|
|
|
|
|
|
"debug"
|
|
|
|
|
|
|
|
|
"notice"
|
|
|
|
|
|
|
|
|
"info"
|
|
|
|
|
|
|
|
|
"warning"
|
|
|
|
|
|
|
|
|
"error"
|
|
|
|
);
|
|
|
|
admins : Array<
|
|
|
|
{
|
|
|
|
name : string;
|
|
|
|
password : string;
|
|
|
|
}
|
|
|
|
>;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
var _data : (null | type_conf) = null;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @todo mandatory fields
|
|
|
|
*/
|
|
|
|
export async function load(
|
|
|
|
path : (null | string)
|
|
|
|
) : Promise<void>
|
|
|
|
{
|
|
|
|
const conf_raw : any = (
|
|
|
|
(path !== null)
|
|
|
|
? (lib_plankton.json.decode(await lib_plankton.file.read(path)) as type_conf)
|
|
|
|
: {}
|
|
|
|
);
|
|
|
|
_data = {
|
|
|
|
"port": (conf_raw["port"] ?? 7979),
|
|
|
|
"email_domain": (conf_raw["email_domain"] ?? "example.org"),
|
|
|
|
"email_numberbased_address_prefix": (conf_raw["email_numberbased_address_prefix"] ?? "member-"),
|
|
|
|
"email": conf_raw["email"], // TODO: feiner
|
|
|
|
"verification_secret": (conf_raw["verification_secret"] ?? "itsy_bitsy"),
|
|
|
|
"session_lifetime": (conf_raw["session_lifetime"] ?? 900),
|
|
|
|
"session_drop_all_at_start": true,
|
|
|
|
"verbosity": (conf_raw["verbosity"] ?? "notice"),
|
|
|
|
"database_path": (conf_raw["database_path"] ?? "data.sqlite"),
|
|
|
|
"admins": (conf_raw["admins"] ?? []),
|
|
|
|
};
|
|
|
|
return Promise.resolve<void>(undefined);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
export function get(
|
|
|
|
) : any
|
|
|
|
{
|
|
|
|
if (_data === null) {
|
|
|
|
throw (new Error("conf not loaded yet"));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return _data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|