Fix backend linting

This commit is contained in:
Jamie Curnow committed 2026-05-13 13:40:06 +10:00
1 parent c17475968f
commit 7d58c579fa
8 files changed
+25 -25

No files matched your search

+2 -2
View File
@@ -241,7 +241,7 @@ const internalAccessList = {
let row = await query.then(utils.omitRow(omissions())); let row = await query.then(utils.omitRow(omissions()));
if (!row || !row.id) { if (!row?.id) {
throw new errs.ItemNotFoundError(thisData.id); throw new errs.ItemNotFoundError(thisData.id);
} }
if (!skipMasking && typeof row.items !== "undefined" && row.items) { if (!skipMasking && typeof row.items !== "undefined" && row.items) {
@@ -268,7 +268,7 @@ const internalAccessList = {
expand: ["proxy_hosts", "items", "clients"], expand: ["proxy_hosts", "items", "clients"],
}); });
if (!row || !row.id) { if (!row?.id) {
throw new errs.ItemNotFoundError(data.id); throw new errs.ItemNotFoundError(data.id);
} }
+4 -4
View File
@@ -66,7 +66,7 @@ const internalCertificate = {
.andWhere("provider", "letsencrypt") .andWhere("provider", "letsencrypt")
.andWhere("expires_on", "<", expirationThreshold) .andWhere("expires_on", "<", expirationThreshold)
.then((certificates) => { .then((certificates) => {
if (!certificates || !certificates.length) { if (!certificates?.length) {
return null; return null;
} }
@@ -143,7 +143,7 @@ const internalCertificate = {
await internalCertificate.disableInUseHosts(inUseResult); await internalCertificate.disableInUseHosts(inUseResult);
const user = await userModel.query().where("is_deleted", 0).andWhere("id", data.owner_user_id).first(); 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( throw new error.ValidationError(
"A valid email address must be set on your user account to use Let's Encrypt", "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())); const row = await query.then(utils.omitRow(omissions()));
if (!row || !row.id) { if (!row?.id) {
throw new error.ItemNotFoundError(data.id); throw new error.ItemNotFoundError(data.id);
} }
// Custom omissions // Custom omissions
@@ -397,7 +397,7 @@ const internalCertificate = {
await access.can("certificates:delete", data.id); await access.can("certificates:delete", data.id);
const row = await internalCertificate.get(access, { id: data.id }); const row = await internalCertificate.get(access, { id: data.id });
if (!row || !row.id) { if (!row?.id) {
throw new error.ItemNotFoundError(data.id); throw new error.ItemNotFoundError(data.id);
} }
+4 -4
View File
@@ -206,7 +206,7 @@ const internalDeadHost = {
} }
const row = await query.then(utils.omitRow(omissions())); const row = await query.then(utils.omitRow(omissions()));
if (!row || !row.id) { if (!row?.id) {
throw new errs.ItemNotFoundError(data.id); throw new errs.ItemNotFoundError(data.id);
} }
// Custom omissions // Custom omissions
@@ -226,7 +226,7 @@ const internalDeadHost = {
delete: async (access, data) => { delete: async (access, data) => {
await access.can("dead_hosts:delete", data.id) await access.can("dead_hosts:delete", data.id)
const row = await internalDeadHost.get(access, { id: data.id }); const row = await internalDeadHost.get(access, { id: data.id });
if (!row || !row.id) { if (!row?.id) {
throw new errs.ItemNotFoundError(data.id); throw new errs.ItemNotFoundError(data.id);
} }
@@ -264,7 +264,7 @@ const internalDeadHost = {
id: data.id, id: data.id,
expand: ["certificate", "owner"], expand: ["certificate", "owner"],
}); });
if (!row || !row.id) { if (!row?.id) {
throw new errs.ItemNotFoundError(data.id); throw new errs.ItemNotFoundError(data.id);
} }
if (row.enabled) { if (row.enabled) {
@@ -303,7 +303,7 @@ const internalDeadHost = {
disable: async (access, data) => { disable: async (access, data) => {
await access.can("dead_hosts:update", data.id) await access.can("dead_hosts:update", data.id)
const row = await internalDeadHost.get(access, { id: data.id }); const row = await internalDeadHost.get(access, { id: data.id });
if (!row || !row.id) { if (!row?.id) {
throw new errs.ItemNotFoundError(data.id); throw new errs.ItemNotFoundError(data.id);
} }
if (!row.enabled) { if (!row.enabled) {
+4 -4
View File
@@ -253,7 +253,7 @@ const internalProxyHost = {
return query.then(utils.omitRow(omissions())); return query.then(utils.omitRow(omissions()));
}) })
.then((row) => { .then((row) => {
if (!row || !row.id) { if (!row?.id) {
throw new errs.ItemNotFoundError(thisData.id); throw new errs.ItemNotFoundError(thisData.id);
} }
const thisRow = internalHost.cleanRowCertificateMeta(row); const thisRow = internalHost.cleanRowCertificateMeta(row);
@@ -279,7 +279,7 @@ const internalProxyHost = {
return internalProxyHost.get(access, { id: data.id }); return internalProxyHost.get(access, { id: data.id });
}) })
.then((row) => { .then((row) => {
if (!row || !row.id) { if (!row?.id) {
throw new errs.ItemNotFoundError(data.id); throw new errs.ItemNotFoundError(data.id);
} }
@@ -327,7 +327,7 @@ const internalProxyHost = {
}); });
}) })
.then((row) => { .then((row) => {
if (!row || !row.id) { if (!row?.id) {
throw new errs.ItemNotFoundError(data.id); throw new errs.ItemNotFoundError(data.id);
} }
if (row.enabled) { if (row.enabled) {
@@ -375,7 +375,7 @@ const internalProxyHost = {
return internalProxyHost.get(access, { id: data.id }); return internalProxyHost.get(access, { id: data.id });
}) })
.then((row) => { .then((row) => {
if (!row || !row.id) { if (!row?.id) {
throw new errs.ItemNotFoundError(data.id); throw new errs.ItemNotFoundError(data.id);
} }
if (!row.enabled) { if (!row.enabled) {
+4 -4
View File
@@ -251,7 +251,7 @@ const internalRedirectionHost = {
}) })
.then((row) => { .then((row) => {
let thisRow = row; let thisRow = row;
if (!thisRow || !thisRow.id) { if (!thisRow?.id) {
throw new errs.ItemNotFoundError(thisData.id); throw new errs.ItemNotFoundError(thisData.id);
} }
thisRow = internalHost.cleanRowCertificateMeta(thisRow); thisRow = internalHost.cleanRowCertificateMeta(thisRow);
@@ -277,7 +277,7 @@ const internalRedirectionHost = {
return internalRedirectionHost.get(access, { id: data.id }); return internalRedirectionHost.get(access, { id: data.id });
}) })
.then((row) => { .then((row) => {
if (!row || !row.id) { if (!row?.id) {
throw new errs.ItemNotFoundError(data.id); throw new errs.ItemNotFoundError(data.id);
} }
@@ -325,7 +325,7 @@ const internalRedirectionHost = {
}); });
}) })
.then((row) => { .then((row) => {
if (!row || !row.id) { if (!row?.id) {
throw new errs.ItemNotFoundError(data.id); throw new errs.ItemNotFoundError(data.id);
} }
if (row.enabled) { if (row.enabled) {
@@ -373,7 +373,7 @@ const internalRedirectionHost = {
return internalRedirectionHost.get(access, { id: data.id }); return internalRedirectionHost.get(access, { id: data.id });
}) })
.then((row) => { .then((row) => {
if (!row || !row.id) { if (!row?.id) {
throw new errs.ItemNotFoundError(data.id); throw new errs.ItemNotFoundError(data.id);
} }
if (!row.enabled) { if (!row.enabled) {
+4 -4
View File
@@ -200,7 +200,7 @@ const internalStream = {
}) })
.then((row) => { .then((row) => {
let thisRow = row; let thisRow = row;
if (!thisRow || !thisRow.id) { if (!thisRow?.id) {
throw new errs.ItemNotFoundError(thisData.id); throw new errs.ItemNotFoundError(thisData.id);
} }
thisRow = internalHost.cleanRowCertificateMeta(thisRow); thisRow = internalHost.cleanRowCertificateMeta(thisRow);
@@ -226,7 +226,7 @@ const internalStream = {
return internalStream.get(access, { id: data.id }); return internalStream.get(access, { id: data.id });
}) })
.then((row) => { .then((row) => {
if (!row || !row.id) { if (!row?.id) {
throw new errs.ItemNotFoundError(data.id); throw new errs.ItemNotFoundError(data.id);
} }
@@ -274,7 +274,7 @@ const internalStream = {
}); });
}) })
.then((row) => { .then((row) => {
if (!row || !row.id) { if (!row?.id) {
throw new errs.ItemNotFoundError(data.id); throw new errs.ItemNotFoundError(data.id);
} }
if (row.enabled) { if (row.enabled) {
@@ -322,7 +322,7 @@ const internalStream = {
return internalStream.get(access, { id: data.id }); return internalStream.get(access, { id: data.id });
}) })
.then((row) => { .then((row) => {
if (!row || !row.id) { if (!row?.id) {
throw new errs.ItemNotFoundError(data.id); throw new errs.ItemNotFoundError(data.id);
} }
if (!row.enabled) { if (!row.enabled) {
+1 -1
View File
@@ -171,7 +171,7 @@ const internalUser = {
return query.then(utils.omitRow(omissions())); return query.then(utils.omitRow(omissions()));
}) })
.then((row) => { .then((row) => {
if (!row || !row.id) { if (!row?.id) {
throw new errs.ItemNotFoundError(thisData.id); throw new errs.ItemNotFoundError(thisData.id);
} }
// Custom omissions // Custom omissions
@@ -10,7 +10,7 @@ const migrateName = "trust_forwarded_proto";
* @param {Object} knex * @param {Object} knex
* @returns {Promise} * @returns {Promise}
*/ */
const up = function (knex) { const up = (knex) => {
logger.info(`[${migrateName}] Migrating Up...`); logger.info(`[${migrateName}] Migrating Up...`);
return knex.schema return knex.schema
@@ -28,7 +28,7 @@ const up = function (knex) {
* @param {Object} knex * @param {Object} knex
* @returns {Promise} * @returns {Promise}
*/ */
const down = function (knex) { const down = (knex) => {
logger.info(`[${migrateName}] Migrating Down...`); logger.info(`[${migrateName}] Migrating Down...`);
return knex.schema return knex.schema