From b2925ef2579050c484a552f2cd9c0ffed11fb1e9 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sat, 15 Oct 2022 20:05:32 +0300 Subject: Bug fixes & started setup.sh --- server.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'server.js') diff --git a/server.js b/server.js index d112d76..3172e75 100644 --- a/server.js +++ b/server.js @@ -35,7 +35,7 @@ async function init() ]); - // https options, you need to get a certificate in the file ../Certificate for the server to work + // https options, you need to get a certificate in the file ../Certificate for the server to work const httpsOpts = { key: httpsKey, cert: httpsCert @@ -264,10 +264,21 @@ async function buildMain(args) [week, day] ) ]); - res["food-header"] = `${food[0].header} ${food[0].datestring}`; - res["vege-header"] = vege[0].header; - res["food"] = food[0].food; - res["vege"] = vege[0].food; + + if (food[0] !== undefined) { + res["food-header"] = `${food[0].header} ${food[0].datestring}`; + res["food"] = food[0].food; + } else { + res["food-header"] = `Kouluruoka ${weekdays[day]}`; + res["food"] = "Päivän ruoka puuttuu tietokannasta."; + } + if (food[1] !== undefined) { + res["vege-header"] = vege[0].header; + res["vege"] = vege[0].food; + } else { + res["vege-header"] = `Kasvisruoka ${weekdays[day]}`; + res["vege"] = "Päivän kasvisruoka puuttuu tietokannasta." + } data_string = build_replace(data_string, res); -- cgit v1.2.3