From 84f45fa16ae0c196aaf02627267b3f61cf1970b0 Mon Sep 17 00:00:00 2001 From: Neshura Date: Wed, 3 Jan 2024 21:09:58 +0100 Subject: [PATCH] Fix crash on /services page when credentials file not present --- src/routes/services/+page.server.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/routes/services/+page.server.ts b/src/routes/services/+page.server.ts index f990af2..24d397b 100644 --- a/src/routes/services/+page.server.ts +++ b/src/routes/services/+page.server.ts @@ -5,9 +5,12 @@ export async function load() { const credFile = './credentials.json'; const socket = io('https://status.neshweb.net/'); - let credentials: { username: string; password: string }; + let credentials = { + username: '', + password: '' + }; if (fs.existsSync(credFile)) { - let buf = fs.readFileSync(credFile); + const buf = fs.readFileSync(credFile); credentials = JSON.parse(buf.toString()); } else { console.error('Credentials File does not exist, Socket.io connection will not work.');