52 lines
704 B
TypeScript
52 lines
704 B
TypeScript
namespace formgen.conf
|
|
{
|
|
|
|
/**
|
|
*/
|
|
export type type_data = {
|
|
zerez : {
|
|
fake : boolean;
|
|
base_url : string;
|
|
token_url : string;
|
|
scope : string;
|
|
client_id : string;
|
|
client_secret : string;
|
|
};
|
|
};
|
|
|
|
|
|
/**
|
|
*/
|
|
var _data : (null | type_data) = null;
|
|
|
|
|
|
/**
|
|
*/
|
|
export async function initialize(
|
|
path : string
|
|
) : Promise<void>
|
|
{
|
|
const content : string = await formgen.helpers.file.read_text(path);
|
|
const data : type_data = (formgen.helpers.json.decode(content) as type_data);
|
|
_data = data;
|
|
}
|
|
|
|
|
|
/**
|
|
* @todo sanitize
|
|
*/
|
|
export function get(
|
|
) : type_data
|
|
{
|
|
if (_data === null)
|
|
{
|
|
throw (new Error("not initialized"));
|
|
}
|
|
else
|
|
{
|
|
return _data;
|
|
}
|
|
}
|
|
|
|
}
|