diff --git a/backend/internal/access-list.js b/backend/internal/access-list.js index 60a7105db..d82e60346 100644 --- a/backend/internal/access-list.js +++ b/backend/internal/access-list.js @@ -241,7 +241,7 @@ const internalAccessList = { let row = await query.then(utils.omitRow(omissions())); - if (!row || !row.id) { + if (!row?.id) { throw new errs.ItemNotFoundError(thisData.id); } if (!skipMasking && typeof row.items !== "undefined" && row.items) { @@ -268,7 +268,7 @@ const internalAccessList = { expand: ["proxy_hosts", "items", "clients"], }); - if (!row || !row.id) { + if (!row?.id) { throw new errs.ItemNotFoundError(data.id); } diff --git a/backend/internal/certificate.js b/backend/internal/certificate.js index 499e14635..59c13bf69 100644 --- a/backend/internal/certificate.js +++ b/backend/internal/certificate.js @@ -66,7 +66,7 @@ const internalCertificate = { .andWhere("provider", "letsencrypt") .andWhere("expires_on", "<", expirationThreshold) .then((certificates) => { - if (!certificates || !certificates.length) { + if (!certificates?.length) { return null; } @@ -143,7 +143,7 @@ const internalCertificate = { await internalCertificate.disableInUseHosts(inUseResult); const user = await userModel.query().where("is_deleted", 0).andWhere("id", data.owner_user_id).first(); - if (!user || !user.email) { + if (!user?.email) { throw new error.ValidationError( "A valid email address must be set on your user account to use Let's Encrypt", ); @@ -305,7 +305,7 @@ const internalCertificate = { } const row = await query.then(utils.omitRow(omissions())); - if (!row || !row.id) { + if (!row?.id) { throw new error.ItemNotFoundError(data.id); } // Custom omissions @@ -397,7 +397,7 @@ const internalCertificate = { await access.can("certificates:delete", data.id); const row = await internalCertificate.get(access, { id: data.id }); - if (!row || !row.id) { + if (!row?.id) { throw new error.ItemNotFoundError(data.id); } diff --git a/backend/internal/dead-host.js b/backend/internal/dead-host.js index 34c94fda9..ee27e53cc 100644 --- a/backend/internal/dead-host.js +++ b/backend/internal/dead-host.js @@ -206,7 +206,7 @@ const internalDeadHost = { } const row = await query.then(utils.omitRow(omissions())); - if (!row || !row.id) { + if (!row?.id) { throw new errs.ItemNotFoundError(data.id); } // Custom omissions @@ -226,7 +226,7 @@ const internalDeadHost = { delete: async (access, data) => { await access.can("dead_hosts:delete", data.id) const row = await internalDeadHost.get(access, { id: data.id }); - if (!row || !row.id) { + if (!row?.id) { throw new errs.ItemNotFoundError(data.id); } @@ -264,7 +264,7 @@ const internalDeadHost = { id: data.id, expand: ["certificate", "owner"], }); - if (!row || !row.id) { + if (!row?.id) { throw new errs.ItemNotFoundError(data.id); } if (row.enabled) { @@ -303,7 +303,7 @@ const internalDeadHost = { disable: async (access, data) => { await access.can("dead_hosts:update", data.id) const row = await internalDeadHost.get(access, { id: data.id }); - if (!row || !row.id) { + if (!row?.id) { throw new errs.ItemNotFoundError(data.id); } if (!row.enabled) { diff --git a/backend/internal/proxy-host.js b/backend/internal/proxy-host.js index 34475c99f..2c159d48a 100644 --- a/backend/internal/proxy-host.js +++ b/backend/internal/proxy-host.js @@ -253,7 +253,7 @@ const internalProxyHost = { return query.then(utils.omitRow(omissions())); }) .then((row) => { - if (!row || !row.id) { + if (!row?.id) { throw new errs.ItemNotFoundError(thisData.id); } const thisRow = internalHost.cleanRowCertificateMeta(row); @@ -279,7 +279,7 @@ const internalProxyHost = { return internalProxyHost.get(access, { id: data.id }); }) .then((row) => { - if (!row || !row.id) { + if (!row?.id) { throw new errs.ItemNotFoundError(data.id); } @@ -327,7 +327,7 @@ const internalProxyHost = { }); }) .then((row) => { - if (!row || !row.id) { + if (!row?.id) { throw new errs.ItemNotFoundError(data.id); } if (row.enabled) { @@ -375,7 +375,7 @@ const internalProxyHost = { return internalProxyHost.get(access, { id: data.id }); }) .then((row) => { - if (!row || !row.id) { + if (!row?.id) { throw new errs.ItemNotFoundError(data.id); } if (!row.enabled) { diff --git a/backend/internal/redirection-host.js b/backend/internal/redirection-host.js index 5237859cf..542439fd3 100644 --- a/backend/internal/redirection-host.js +++ b/backend/internal/redirection-host.js @@ -251,7 +251,7 @@ const internalRedirectionHost = { }) .then((row) => { let thisRow = row; - if (!thisRow || !thisRow.id) { + if (!thisRow?.id) { throw new errs.ItemNotFoundError(thisData.id); } thisRow = internalHost.cleanRowCertificateMeta(thisRow); @@ -277,7 +277,7 @@ const internalRedirectionHost = { return internalRedirectionHost.get(access, { id: data.id }); }) .then((row) => { - if (!row || !row.id) { + if (!row?.id) { throw new errs.ItemNotFoundError(data.id); } @@ -325,7 +325,7 @@ const internalRedirectionHost = { }); }) .then((row) => { - if (!row || !row.id) { + if (!row?.id) { throw new errs.ItemNotFoundError(data.id); } if (row.enabled) { @@ -373,7 +373,7 @@ const internalRedirectionHost = { return internalRedirectionHost.get(access, { id: data.id }); }) .then((row) => { - if (!row || !row.id) { + if (!row?.id) { throw new errs.ItemNotFoundError(data.id); } if (!row.enabled) { diff --git a/backend/internal/stream.js b/backend/internal/stream.js index 909c92f84..a68e09e02 100644 --- a/backend/internal/stream.js +++ b/backend/internal/stream.js @@ -200,7 +200,7 @@ const internalStream = { }) .then((row) => { let thisRow = row; - if (!thisRow || !thisRow.id) { + if (!thisRow?.id) { throw new errs.ItemNotFoundError(thisData.id); } thisRow = internalHost.cleanRowCertificateMeta(thisRow); @@ -226,7 +226,7 @@ const internalStream = { return internalStream.get(access, { id: data.id }); }) .then((row) => { - if (!row || !row.id) { + if (!row?.id) { throw new errs.ItemNotFoundError(data.id); } @@ -274,7 +274,7 @@ const internalStream = { }); }) .then((row) => { - if (!row || !row.id) { + if (!row?.id) { throw new errs.ItemNotFoundError(data.id); } if (row.enabled) { @@ -322,7 +322,7 @@ const internalStream = { return internalStream.get(access, { id: data.id }); }) .then((row) => { - if (!row || !row.id) { + if (!row?.id) { throw new errs.ItemNotFoundError(data.id); } if (!row.enabled) { diff --git a/backend/internal/user.js b/backend/internal/user.js index d13931d54..176e34902 100644 --- a/backend/internal/user.js +++ b/backend/internal/user.js @@ -171,7 +171,7 @@ const internalUser = { return query.then(utils.omitRow(omissions())); }) .then((row) => { - if (!row || !row.id) { + if (!row?.id) { throw new errs.ItemNotFoundError(thisData.id); } // Custom omissions diff --git a/backend/migrations/20260131163528_trust_forwarded_proto.js b/backend/migrations/20260131163528_trust_forwarded_proto.js index 546cbca67..c32c6fb69 100644 --- a/backend/migrations/20260131163528_trust_forwarded_proto.js +++ b/backend/migrations/20260131163528_trust_forwarded_proto.js @@ -10,7 +10,7 @@ const migrateName = "trust_forwarded_proto"; * @param {Object} knex * @returns {Promise} */ -const up = function (knex) { +const up = (knex) => { logger.info(`[${migrateName}] Migrating Up...`); return knex.schema @@ -28,7 +28,7 @@ const up = function (knex) { * @param {Object} knex * @returns {Promise} */ -const down = function (knex) { +const down = (knex) => { logger.info(`[${migrateName}] Migrating Down...`); return knex.schema