From c28fe49a7a303ef0440ccffd830e4949a1f2381f Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Tue, 18 Oct 2022 21:41:31 +0300 Subject: Enhanced robustness in retrieving the example input and in the init (at reboot) script. The server errored out if the database was empty and there came a request, as it didn't check for empty arrays in dbparse.js in the function getRandomIndex. Fixed by adding handling & recursion limit. Added in init.sh a check to see if logging in to MySQL is possible to prevent errors at startup. --- server.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'server.js') diff --git a/server.js b/server.js index fcfa1ea..c180b71 100644 --- a/server.js +++ b/server.js @@ -252,6 +252,8 @@ async function buildMain(args) // get the example input res["example-input"] = await DBPARSE.randomIndex(day, SQLDB); + if (res["example-input"] === null) + res["example-input"] = ""; // get the day let weekdays = ["ma", "ti", "ke", "to", "pe", "la", "su"]; -- cgit v1.2.3