Fix crash on /services page when credentials file not present
Some checks failed
Run Tests on Code / test (push) Successful in 9m44s
Build and Release Docker Image / test (push) Has been cancelled
Build and Release Docker Image / build (push) Has been cancelled
Build and Release Docker Image / release (push) Has been cancelled

This commit is contained in:
Neshura 2024-01-03 21:09:58 +01:00
parent 769818b4f4
commit 1d2be60c1e
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C

View file

@ -5,9 +5,12 @@ export async function load() {
const credFile = './credentials.json'; const credFile = './credentials.json';
const socket = io('https://status.neshweb.net/'); const socket = io('https://status.neshweb.net/');
let credentials: { username: string; password: string }; let credentials = {
username: '',
password: ''
};
if (fs.existsSync(credFile)) { if (fs.existsSync(credFile)) {
let buf = fs.readFileSync(credFile); const buf = fs.readFileSync(credFile);
credentials = JSON.parse(buf.toString()); credentials = JSON.parse(buf.toString());
} else { } else {
console.error('Credentials File does not exist, Socket.io connection will not work.'); console.error('Credentials File does not exist, Socket.io connection will not work.');