π A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
Vue awesomedashboarddockerhomelabhomepagemitnodejsorganizationproductivitypwaself-hostedstartpagevue
π₯ Some small catch blocks for unexpected shapes
Alicia Sykesb8d5ebe508ed
diff --git a/services/endpoints/get-user.js b/services/endpoints/get-user.jsindex 12055365..9f1ac22b 100644--- a/services/endpoints/get-user.js+++ b/services/endpoints/get-user.js@@ -1,7 +1,7 @@module.exports = (config, req) => {try {if (config.appConfig?.auth?.enableHeaderAuth) {- const { userHeader } = config.appConfig.auth.headerAuth;+ const { userHeader = 'Remote-User' } = config.appConfig.auth.headerAuth;const { proxyWhitelist } = config.appConfig.auth.headerAuth;if (proxyWhitelist.includes(req.socket.remoteAddress)) {return { success: true, user: req.headers[userHeader.toLowerCase()] };diff --git a/services/utils/ssl-server.js b/services/utils/ssl-server.jsindex aee7c284..c25dc4dd 100644--- a/services/utils/ssl-server.js+++ b/services/utils/ssl-server.js@@ -14,7 +14,7 @@ const httpsCerts = {const isDocker = !!process.env.IS_DOCKER;const SSLPort = process.env.SSL_PORT || (isDocker ? 443 : 4001);-const redirectHttps = process.env.REDIRECT_HTTPS ? process.env.REDIRECT_HTTPS : true;+const redirectHttps = process.env.REDIRECT_HTTPS !== 'false';const printNotSoGood = (msg) => {console.log(`SSL Not Enabled: ${msg}`);diff --git a/src/mixins/GlancesMixin.js b/src/mixins/GlancesMixin.jsindex 94c43628..e9eab61b 100644--- a/src/mixins/GlancesMixin.js+++ b/src/mixins/GlancesMixin.js@@ -23,7 +23,7 @@ export default {/* Make the request to Glances API, and calls handler function with results* Requires endpoint attribute and processData method to be implemented by child */fetchData() {- this.makeRequest(this.endpoint, this.credentials).then(this.processData);+ this.makeRequest(this.endpoint, this.credentials).then(this.processData).catch(() => {});},/* Returns URL to Glances API endpoint */makeGlancesUrl(apiPath) {diff --git a/src/mixins/ItemMixin.js b/src/mixins/ItemMixin.jsindex fb089cb2..b7186a8d 100644--- a/src/mixins/ItemMixin.js+++ b/src/mixins/ItemMixin.js@@ -206,7 +206,9 @@ export default {if (this.statusResponse) this.statusResponse.successStatus = undefined; // Reset previous response, to show loading staterequest.get(endpoint).then((response) => {- if (response.data) this.statusResponse = response.data;+ if (response.data && typeof response.data === 'object') {+ this.statusResponse = response.data;+ }}).catch(() => { // Something went very wrong.this.statusResponse = {@@ -228,7 +230,7 @@ export default {const endpoint = this.pingCheckApiUrl;request.get(endpoint).then((response) => {- if (response.data) this.pingResponse = response.data;+ if (response.data && typeof response.data === 'object') this.pingResponse = response.data;}).catch(() => { // Something went very wrong.this.pingResponse = {diff --git a/src/mixins/NextcloudMixin.js b/src/mixins/NextcloudMixin.jsindex 01cd1cc6..52378f10 100644--- a/src/mixins/NextcloudMixin.js+++ b/src/mixins/NextcloudMixin.js@@ -44,7 +44,7 @@ export default {/* The user provided Nextcloud username */username() {if (!this.options.username) this.error('A username is required');- return this.options.username;+ return this.options.username || '';},/* The user provided Nextcloud password */password() {diff --git a/src/utils/SortItems.js b/src/utils/SortItems.jsindex d4de6c12..053c87ea 100644--- a/src/utils/SortItems.js+++ b/src/utils/SortItems.js@@ -13,7 +13,7 @@ const byTitle = (items) => [...items].sort(const byUsage = (items, key) => {const counts = readUsage(key);const get = (item) => counts[item.id] || 0;- return [...items].reverse().sort((a, b) => (get(a) < get(b) ? 1 : -1));+ return [...items].sort((a, b) => get(b) - get(a));};const shuffled = (items) => itemsdiff --git a/src/utils/config/SectionHelpers.js b/src/utils/config/SectionHelpers.jsindex 9adf42d1..013cdcb5 100644--- a/src/utils/config/SectionHelpers.js+++ b/src/utils/config/SectionHelpers.js@@ -15,9 +15,9 @@ export const shouldBeVisible = (routeName) => {/* Based on section title, item name and index, return a string value for ID */const makeItemId = (sectionStr, itemStr, index) => {- const sectionTitle = sectionStr || `unlabeledSec_${Math.random()}`;+ const sectionTitle = String(sectionStr || `unlabeledSec_${Math.random()}`);const charSum = sectionTitle.split('').map((a) => a.charCodeAt(0)).reduce((x, y) => x + y);- const newItemStr = itemStr || `unknown_${Math.random()}`;+ const newItemStr = String(itemStr || `unknown_${Math.random()}`);const itemTitleStr = newItemStr.replace(/\s+/g, '-').replace(/[^a-zA-Z ]/g, '').toLowerCase();return `${index}_${charSum}_${itemTitleStr}`;};