From 6b0d0f46995d9b155cfe0615fd42545ec3e1db31 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Fri, 25 Apr 2025 12:16:38 -0400 Subject: [PATCH 01/39] added endpoint to query by domain --- backend/internal/proxy-host.js | 50 +++++++++++++++++++++++++++++ backend/routes/nginx/proxy_hosts.js | 45 ++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/backend/internal/proxy-host.js b/backend/internal/proxy-host.js index 32f2bc0dca..81fc519724 100644 --- a/backend/internal/proxy-host.js +++ b/backend/internal/proxy-host.js @@ -258,6 +258,56 @@ const internalProxyHost = { }); }, + /** + * @param {Access} access + * @param {Object} data + * @param {String} data.domain + * @param {Array} [data.expand] + * @param {Array} [data.omit] + * @return {Promise} + */ + getByDomain: (access, data) => { + if (typeof data === 'undefined') { + data = {}; + } + + return access.can('proxy_hosts:get', data.domain) + .then((access_data) => { + let query = proxyHostModel + .query() + .where('is_deleted', 0) + .andWhereRaw("domain_names::jsonb @> ?::jsonb", [JSON.stringify([data.domain])]) + .allowGraph('[owner,access_list.[clients,items],certificate]') + .modify(function(queryBuilder) { + if (data.expand) { + queryBuilder.withGraphFetched(`[${data.expand.join(', ')}]`); + } + }) + .first(); + + if (access_data.permission_visibility !== 'all') { + query.andWhere('owner_user_id', access.token.getUserId(1)); + } + + if (typeof data.expand !== 'undefined' && data.expand !== null) { + query.withGraphFetched('[' + data.expand.join(', ') + ']'); + } + + return query.then(utils.omitRow(omissions())); + }) + .then((row) => { + if (!row || !row.id) { + throw new error.ItemNotFoundError(data.id); + } + row = internalHost.cleanRowCertificateMeta(row); + // Custom omissions + if (typeof data.omit !== 'undefined' && data.omit !== null) { + row = _.omit(row, data.omit); + } + return row; + }); + }, + /** * @param {Access} access * @param {Object} data diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index 3be4582a87..c2257d5a42 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -4,6 +4,7 @@ const jwtdecode = require('../../lib/express/jwt-decode'); const apiValidator = require('../../lib/validator/api'); const internalProxyHost = require('../../internal/proxy-host'); const schema = require('../../schema'); +const {castJsonIfNeed} = require('../../lib/helpers'); let router = express.Router({ caseSensitive: true, @@ -114,6 +115,50 @@ router .catch(next); }) +/** + * Specific proxy-host + * + * /api/nginx/proxy-hosts/domain/:domain + */ +router + .route('/domain/:domain') + .options((req, res) => { + res.sendStatus(204); + }) + .all(jwtdecode()) + + /** + * GET /api/nginx/proxy-hosts/domain/:domain + * + * Retrieve a specific proxy-host by domain + */ + .get((req, res, next) => { + validator({ + required: ['domain'], + additionalProperties: false, + properties: { + domain: {type: "string"}, + expand: { + $ref: 'common#/properties/expand' + } + } + }, { + domain: req.params.domain, + expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null) + }) + .then((data) => { + return internalProxyHost.getByDomain(res.locals.access, { + domain: data.domain, + expand: data.expand + }); + }) + .then((row) => { + res.status(200) + .send(row); + }) + .catch(next); + }) + /** * PUT /api/nginx/proxy-hosts/123 * From 86c834ffbccdbad969a1e4c0479fe032035d111d Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Fri, 25 Apr 2025 12:33:49 -0400 Subject: [PATCH 02/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index c2257d5a42..fefbf4503b 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -4,7 +4,6 @@ const jwtdecode = require('../../lib/express/jwt-decode'); const apiValidator = require('../../lib/validator/api'); const internalProxyHost = require('../../internal/proxy-host'); const schema = require('../../schema'); -const {castJsonIfNeed} = require('../../lib/helpers'); let router = express.Router({ caseSensitive: true, From ba518d2d1497e3093460e65e6770c62c44a558b4 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Fri, 25 Apr 2025 12:37:58 -0400 Subject: [PATCH 03/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index fefbf4503b..ad8fb7e20b 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -112,7 +112,7 @@ router .send(row); }) .catch(next); - }) + }); /** * Specific proxy-host @@ -133,10 +133,12 @@ router */ .get((req, res, next) => { validator({ - required: ['domain'], + required: ['domain'], additionalProperties: false, properties: { - domain: {type: "string"}, + domain: { + type: 'string' + }, expand: { $ref: 'common#/properties/expand' } @@ -156,7 +158,7 @@ router .send(row); }) .catch(next); - }) + }); /** * PUT /api/nginx/proxy-hosts/123 From 6a7214caab2587074ea98123080321cdd1316830 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Fri, 25 Apr 2025 12:39:06 -0400 Subject: [PATCH 04/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index ad8fb7e20b..2020f17f97 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -145,7 +145,7 @@ router } }, { domain: req.params.domain, - expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null) + expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null) }) .then((data) => { return internalProxyHost.getByDomain(res.locals.access, { From 8178951ff7fa16f81f71c228f29405ebf00f3ce4 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Fri, 25 Apr 2025 12:45:38 -0400 Subject: [PATCH 05/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 70 ++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 12 deletions(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index 2020f17f97..ba9bf0729e 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -117,39 +117,39 @@ router /** * Specific proxy-host * - * /api/nginx/proxy-hosts/domain/:domain + * /api/nginx/proxy-hosts/123 */ router - .route('/domain/:domain') + .route('/:host_id') .options((req, res) => { res.sendStatus(204); }) .all(jwtdecode()) /** - * GET /api/nginx/proxy-hosts/domain/:domain + * GET /api/nginx/proxy-hosts/123 * - * Retrieve a specific proxy-host by domain + * Retrieve a specific proxy-host */ .get((req, res, next) => { validator({ - required: ['domain'], + required: ['host_id'], additionalProperties: false, properties: { - domain: { - type: 'string' + host_id: { + $ref: 'common#/properties/id' }, expand: { $ref: 'common#/properties/expand' } } }, { - domain: req.params.domain, - expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null) + host_id: req.params.host_id, + expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null) }) .then((data) => { - return internalProxyHost.getByDomain(res.locals.access, { - domain: data.domain, + return internalProxyHost.get(res.locals.access, { + id: parseInt(data.host_id, 10), expand: data.expand }); }) @@ -158,7 +158,7 @@ router .send(row); }) .catch(next); - }); + }) /** * PUT /api/nginx/proxy-hosts/123 @@ -192,6 +192,52 @@ router .catch(next); }); +/** + * Specific proxy-host by domain + * + * /api/nginx/proxy-hosts/domain/:domain + */ +router + .route('/domain/:domain') + .options((req, res) => { + res.sendStatus(204); + }) + .all(jwtdecode()) + + /** + * GET /api/nginx/proxy-hosts/domain/:domain + * + * Retrieve a specific proxy-host by domain + */ + .get((req, res, next) => { + validator({ + required: ['domain'], + additionalProperties: false, + properties: { + domain: { + type: 'string' + }, + expand: { + $ref: 'common#/properties/expand' + } + } + }, { + domain: req.params.domain, + expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null) + }) + .then((data) => { + return internalProxyHost.getByDomain(res.locals.access, { + domain: data.domain, + expand: data.expand + }); + }) + .then((row) => { + res.status(200) + .send(row); + }) + .catch(next); + }); + /** * Enable proxy-host * From b60647795dc57fa360a5c81ffa941deec84337bb Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Fri, 25 Apr 2025 12:49:34 -0400 Subject: [PATCH 06/39] added endpoint to query by domain --- backend/internal/proxy-host.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/internal/proxy-host.js b/backend/internal/proxy-host.js index 81fc519724..8aaf69035a 100644 --- a/backend/internal/proxy-host.js +++ b/backend/internal/proxy-host.js @@ -276,7 +276,7 @@ const internalProxyHost = { let query = proxyHostModel .query() .where('is_deleted', 0) - .andWhereRaw("domain_names::jsonb @> ?::jsonb", [JSON.stringify([data.domain])]) + .andWhereRaw('domain_names::jsonb @> ?::jsonb', [JSON.stringify([data.domain])]) .allowGraph('[owner,access_list.[clients,items],certificate]') .modify(function(queryBuilder) { if (data.expand) { From 37302dd22a99d43af0827f19785cf8734758d5a1 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Fri, 25 Apr 2025 12:55:42 -0400 Subject: [PATCH 07/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 46 ----------------------------- 1 file changed, 46 deletions(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index ba9bf0729e..c123963cb1 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -68,52 +68,6 @@ router .catch(next); }); -/** - * Specific proxy-host - * - * /api/nginx/proxy-hosts/123 - */ -router - .route('/:host_id') - .options((req, res) => { - res.sendStatus(204); - }) - .all(jwtdecode()) - - /** - * GET /api/nginx/proxy-hosts/123 - * - * Retrieve a specific proxy-host - */ - .get((req, res, next) => { - validator({ - required: ['host_id'], - additionalProperties: false, - properties: { - host_id: { - $ref: 'common#/properties/id' - }, - expand: { - $ref: 'common#/properties/expand' - } - } - }, { - host_id: req.params.host_id, - expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null) - }) - .then((data) => { - return internalProxyHost.get(res.locals.access, { - id: parseInt(data.host_id, 10), - expand: data.expand - }); - }) - .then((row) => { - res.status(200) - .send(row); - }) - .catch(next); - }); - /** * Specific proxy-host * From 549408f448e6e96b387bd3f11ec25702133b9d2e Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Mon, 28 Apr 2025 11:24:20 -0400 Subject: [PATCH 08/39] added endpoint to query by domain --- backend/internal/proxy-host.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/internal/proxy-host.js b/backend/internal/proxy-host.js index 8aaf69035a..65947aa87c 100644 --- a/backend/internal/proxy-host.js +++ b/backend/internal/proxy-host.js @@ -276,7 +276,7 @@ const internalProxyHost = { let query = proxyHostModel .query() .where('is_deleted', 0) - .andWhereRaw('domain_names::jsonb @> ?::jsonb', [JSON.stringify([data.domain])]) + .andWhere(castJsonIfNeed('domain_names'), 'like', '%' + data.domain + '%') .allowGraph('[owner,access_list.[clients,items],certificate]') .modify(function(queryBuilder) { if (data.expand) { From 98cd7569555ae048f43d739f97192a69dcfd65bf Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Fri, 25 Apr 2025 12:16:38 -0400 Subject: [PATCH 09/39] added endpoint to query by domain --- backend/internal/proxy-host.js | 50 +++++++++++++++++++++++++++++ backend/routes/nginx/proxy_hosts.js | 44 +++++++++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/backend/internal/proxy-host.js b/backend/internal/proxy-host.js index 3299012a6b..db26457775 100644 --- a/backend/internal/proxy-host.js +++ b/backend/internal/proxy-host.js @@ -266,6 +266,56 @@ const internalProxyHost = { }); }, + /** + * @param {Access} access + * @param {Object} data + * @param {String} data.domain + * @param {Array} [data.expand] + * @param {Array} [data.omit] + * @return {Promise} + */ + getByDomain: (access, data) => { + if (typeof data === 'undefined') { + data = {}; + } + + return access.can('proxy_hosts:get', data.domain) + .then((access_data) => { + let query = proxyHostModel + .query() + .where('is_deleted', 0) + .andWhereRaw("domain_names::jsonb @> ?::jsonb", [JSON.stringify([data.domain])]) + .allowGraph('[owner,access_list.[clients,items],certificate]') + .modify(function(queryBuilder) { + if (data.expand) { + queryBuilder.withGraphFetched(`[${data.expand.join(', ')}]`); + } + }) + .first(); + + if (access_data.permission_visibility !== 'all') { + query.andWhere('owner_user_id', access.token.getUserId(1)); + } + + if (typeof data.expand !== 'undefined' && data.expand !== null) { + query.withGraphFetched('[' + data.expand.join(', ') + ']'); + } + + return query.then(utils.omitRow(omissions())); + }) + .then((row) => { + if (!row || !row.id) { + throw new error.ItemNotFoundError(data.id); + } + row = internalHost.cleanRowCertificateMeta(row); + // Custom omissions + if (typeof data.omit !== 'undefined' && data.omit !== null) { + row = _.omit(row, data.omit); + } + return row; + }); + }, + /** * @param {Access} access * @param {Object} data diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index 7045a195cc..1749a07b57 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -118,6 +118,50 @@ router } }) +/** + * Specific proxy-host + * + * /api/nginx/proxy-hosts/domain/:domain + */ +router + .route('/domain/:domain') + .options((req, res) => { + res.sendStatus(204); + }) + .all(jwtdecode()) + + /** + * GET /api/nginx/proxy-hosts/domain/:domain + * + * Retrieve a specific proxy-host by domain + */ + .get((req, res, next) => { + validator({ + required: ['domain'], + additionalProperties: false, + properties: { + domain: {type: "string"}, + expand: { + $ref: 'common#/properties/expand' + } + } + }, { + domain: req.params.domain, + expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null) + }) + .then((data) => { + return internalProxyHost.getByDomain(res.locals.access, { + domain: data.domain, + expand: data.expand + }); + }) + .then((row) => { + res.status(200) + .send(row); + }) + .catch(next); + }) + /** * PUT /api/nginx/proxy-hosts/123 * From 0165eb237386b275f3d38550612e4bce72455b66 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Fri, 25 Apr 2025 12:39:06 -0400 Subject: [PATCH 10/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index 1749a07b57..3b652d3578 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -147,7 +147,7 @@ router } }, { domain: req.params.domain, - expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null) + expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null) }) .then((data) => { return internalProxyHost.getByDomain(res.locals.access, { From 137bc4a8e9ef54647aa2c46e720c0492fbaa4b18 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Fri, 25 Apr 2025 12:49:34 -0400 Subject: [PATCH 11/39] added endpoint to query by domain --- backend/internal/proxy-host.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/internal/proxy-host.js b/backend/internal/proxy-host.js index db26457775..823544f374 100644 --- a/backend/internal/proxy-host.js +++ b/backend/internal/proxy-host.js @@ -284,7 +284,7 @@ const internalProxyHost = { let query = proxyHostModel .query() .where('is_deleted', 0) - .andWhereRaw("domain_names::jsonb @> ?::jsonb", [JSON.stringify([data.domain])]) + .andWhereRaw('domain_names::jsonb @> ?::jsonb', [JSON.stringify([data.domain])]) .allowGraph('[owner,access_list.[clients,items],certificate]') .modify(function(queryBuilder) { if (data.expand) { From 305dabebe4efc57ff53830b1559bf46a1206948d Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Mon, 28 Apr 2025 11:24:20 -0400 Subject: [PATCH 12/39] added endpoint to query by domain --- backend/internal/proxy-host.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/internal/proxy-host.js b/backend/internal/proxy-host.js index 823544f374..225d7564fb 100644 --- a/backend/internal/proxy-host.js +++ b/backend/internal/proxy-host.js @@ -284,7 +284,7 @@ const internalProxyHost = { let query = proxyHostModel .query() .where('is_deleted', 0) - .andWhereRaw('domain_names::jsonb @> ?::jsonb', [JSON.stringify([data.domain])]) + .andWhere(castJsonIfNeed('domain_names'), 'like', '%' + data.domain + '%') .allowGraph('[owner,access_list.[clients,items],certificate]') .modify(function(queryBuilder) { if (data.expand) { From 818c240a0c197ac135063dbd3a003c922cb3c141 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Mon, 17 Nov 2025 11:00:43 -0500 Subject: [PATCH 13/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 51 +++++++++++++++-------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index 3b652d3578..dfadca9237 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -124,7 +124,7 @@ router * /api/nginx/proxy-hosts/domain/:domain */ router - .route('/domain/:domain') + .route("/domain/:domain") .options((req, res) => { res.sendStatus(204); }) @@ -135,31 +135,32 @@ router * * Retrieve a specific proxy-host by domain */ - .get((req, res, next) => { - validator({ - required: ['domain'], - additionalProperties: false, - properties: { - domain: {type: "string"}, - expand: { - $ref: 'common#/properties/expand' + .get(async (req, res, next) => { + try { + const data = await validator({ + required: ["domain"], + additionalProperties: false, + properties: { + domain: { + type: "string", + }, + expand: { + $ref: "common#/properties/expand" + } } - } - }, { - domain: req.params.domain, - expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null) - }) - .then((data) => { - return internalProxyHost.getByDomain(res.locals.access, { - domain: data.domain, - expand: data.expand - }); - }) - .then((row) => { - res.status(200) - .send(row); - }) - .catch(next); + }, { + domain: req.params.domain, + expand: (typeof req.query.expand === "string" ? req.query.expand.split(",") : null) + }); + const row = internalProxyHost.getByDomain(res.locals.access, { + domain: data.domain, + expand: data.expand + }); + res.status(200).send(row); + } catch (err) { + debug(logger, `${req.method.toUpperCase()} ${req.path}: ${err}`); + next(err); + } }) /** From 335459073a86ef9280a1539a05f3027b51d5c4df Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Mon, 17 Nov 2025 11:27:52 -0500 Subject: [PATCH 14/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index a4ca9e7373..6b571df7b2 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -125,7 +125,7 @@ router */ router .route("/domain/:domain") - .options((req, res) => { + .options((_, res) => { res.sendStatus(204); }) .all(jwtdecode()) From 5aa71451468502890c172d1fc30b75394103ac27 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Mon, 17 Nov 2025 11:40:37 -0500 Subject: [PATCH 15/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index 6b571df7b2..cdd40c747a 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -119,7 +119,7 @@ router }) /** - * Specific proxy-host + * Specific proxy-host by domain * * /api/nginx/proxy-hosts/domain/:domain */ From 225006d3d29d5546d36153898dff3d01b7267069 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Mon, 17 Nov 2025 11:49:06 -0500 Subject: [PATCH 16/39] added endpoint to query by domain --- backend/internal/proxy-host.js | 68 +++++----------------------------- 1 file changed, 9 insertions(+), 59 deletions(-) diff --git a/backend/internal/proxy-host.js b/backend/internal/proxy-host.js index 5c3961c09b..bf72ae6e06 100644 --- a/backend/internal/proxy-host.js +++ b/backend/internal/proxy-host.js @@ -275,67 +275,17 @@ const internalProxyHost = { * @return {Promise} */ getByDomain: (access, data) => { - if (typeof data === 'undefined') { + if (typeof data === "undefined") { data = {}; } - return access.can('proxy_hosts:get', data.domain) + return access.can("proxy_hosts:get", data.domain) .then((access_data) => { let query = proxyHostModel .query() - .where('is_deleted', 0) - .andWhere(castJsonIfNeed('domain_names'), 'like', '%' + data.domain + '%') - .allowGraph('[owner,access_list.[clients,items],certificate]') - .modify(function(queryBuilder) { - if (data.expand) { - queryBuilder.withGraphFetched(`[${data.expand.join(', ')}]`); - } - }) - .first(); - - if (access_data.permission_visibility !== 'all') { - query.andWhere('owner_user_id', access.token.getUserId(1)); - } - - if (typeof data.expand !== 'undefined' && data.expand !== null) { - query.withGraphFetched('[' + data.expand.join(', ') + ']'); - } - - return query.then(utils.omitRow(omissions())); - }) - .then((row) => { - if (!row || !row.id) { - throw new error.ItemNotFoundError(data.id); - } - row = internalHost.cleanRowCertificateMeta(row); - // Custom omissions - if (typeof data.omit !== 'undefined' && data.omit !== null) { - row = _.omit(row, data.omit); - } - return row; - }); - }, - - /** - * @param {Access} access - * @param {Object} data - * @param {String} data.domain - * @param {Array} [data.expand] - * @param {Array} [data.omit] - * @return {Promise} - */ - getByDomain: (access, data) => { - if (typeof data === 'undefined') { - data = {}; - } - - return access.can('proxy_hosts:get', data.domain) - .then((access_data) => { - let query = proxyHostModel - .query() - .where('is_deleted', 0) - .andWhere(castJsonIfNeed('domain_names'), 'like', '%' + data.domain + '%') - .allowGraph('[owner,access_list.[clients,items],certificate]') + .where("is_deleted", 0) + .andWhere(castJsonIfNeed("domain_names"), "like", "%" + data.domain + "%") + .allowGraph("[owner,access_list.[clients,items],certificate]") .modify(function(queryBuilder) { if (data.expand) { queryBuilder.withGraphFetched(`[${data.expand.join(', ')}]`); @@ -343,12 +293,12 @@ const internalProxyHost = { }) .first(); - if (access_data.permission_visibility !== 'all') { - query.andWhere('owner_user_id', access.token.getUserId(1)); + if (access_data.permission_visibility !== "all") { + query.andWhere("owner_user_id", access.token.getUserId(1)); } - if (typeof data.expand !== 'undefined' && data.expand !== null) { - query.withGraphFetched('[' + data.expand.join(', ') + ']'); + if (typeof data.expand !== "undefined" && data.expand !== null) { + query.withGraphFetched(`[${data.expand.join(', ')}]`); } return query.then(utils.omitRow(omissions())); From 6e938fdadaf6538b066f92705ea953a96ba980b9 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Mon, 17 Nov 2025 12:00:01 -0500 Subject: [PATCH 17/39] added endpoint to query by domain --- backend/internal/proxy-host.js | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/backend/internal/proxy-host.js b/backend/internal/proxy-host.js index bf72ae6e06..96c84c1de6 100644 --- a/backend/internal/proxy-host.js +++ b/backend/internal/proxy-host.js @@ -40,7 +40,7 @@ const internalProxyHost = { return Promise.all(domain_name_check_promises).then((check_results) => { check_results.map((result) => { if (result.is_taken) { - throw new errs.ValidationError(`${result.hostname} is already in use`); + throw new errs.ValidationError(result.hostname + " is already in use"); } return true; }); @@ -137,7 +137,7 @@ const internalProxyHost = { return Promise.all(domain_name_check_promises).then((check_results) => { check_results.map((result) => { if (result.is_taken) { - throw new errs.ValidationError(`${result.hostname} is already in use`); + throw new errs.ValidationError(result.hostname + " is already in use"); } return true; }); @@ -151,7 +151,7 @@ const internalProxyHost = { if (row.id !== thisData.id) { // Sanity check that something crazy hasn't happened throw new errs.InternalValidationError( - `Proxy Host could not be updated, IDs do not match: ${row.id} !== ${thisData.id}`, + "Proxy Host could not be updated, IDs do not match: " + row.id + " !== " + thisData.id, ); } @@ -248,7 +248,7 @@ const internalProxyHost = { } if (typeof thisData.expand !== "undefined" && thisData.expand !== null) { - query.withGraphFetched(`[${thisData.expand.join(", ")}]`); + query.withGraphFetched("[" + thisData.expand.join(", ") + "]"); } return query.then(utils.omitRow(omissions())); @@ -275,20 +275,18 @@ const internalProxyHost = { * @return {Promise} */ getByDomain: (access, data) => { - if (typeof data === "undefined") { - data = {}; - } + const thisData = data || {}; - return access.can("proxy_hosts:get", data.domain) + return access.can("proxy_hosts:get", thisData.domain) .then((access_data) => { let query = proxyHostModel .query() .where("is_deleted", 0) - .andWhere(castJsonIfNeed("domain_names"), "like", "%" + data.domain + "%") + .andWhere(castJsonIfNeed("domain_names"), "like", "%" + thisData.domain + "%") .allowGraph("[owner,access_list.[clients,items],certificate]") .modify(function(queryBuilder) { - if (data.expand) { - queryBuilder.withGraphFetched(`[${data.expand.join(', ')}]`); + if (thisData.expand) { + queryBuilder.withGraphFetched("[" + thisData.expand.join(', ') + "]"); } }) .first(); @@ -297,20 +295,20 @@ const internalProxyHost = { query.andWhere("owner_user_id", access.token.getUserId(1)); } - if (typeof data.expand !== "undefined" && data.expand !== null) { - query.withGraphFetched(`[${data.expand.join(', ')}]`); + if (typeof thisData.expand !== "undefined" && thisData.expand !== null) { + query.withGraphFetched("[" + thisData.expand.join(', ') + "]"); } return query.then(utils.omitRow(omissions())); }) .then((row) => { if (!row || !row.id) { - throw new error.ItemNotFoundError(data.id); + throw new error.ItemNotFoundError(thisData.id); } row = internalHost.cleanRowCertificateMeta(row); // Custom omissions - if (typeof data.omit !== 'undefined' && data.omit !== null) { - row = _.omit(row, data.omit); + if (typeof thisData.omit !== 'undefined' && thisData.omit !== null) { + row = _.omit(row, thisData.omit); } return row; }); @@ -486,12 +484,12 @@ const internalProxyHost = { // Query is used for searching if (typeof searchQuery === "string" && searchQuery.length > 0) { query.where(function () { - this.where(castJsonIfNeed("domain_names"), "like", `%${searchQuery}%`); + this.where(castJsonIfNeed("domain_names"), "like", "%" + searchQuery + "%"); }); } if (typeof expand !== "undefined" && expand !== null) { - query.withGraphFetched(`[${expand.join(", ")}]`); + query.withGraphFetched("[" + expand.join(", ") + "]"); } const rows = await query.then(utils.omitRows(omissions())); From c71d18e9710237b78795ae19d8de51b3202a6e61 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Mon, 17 Nov 2025 12:01:02 -0500 Subject: [PATCH 18/39] added endpoint to query by domain --- backend/internal/proxy-host.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/internal/proxy-host.js b/backend/internal/proxy-host.js index 96c84c1de6..34fbbc425b 100644 --- a/backend/internal/proxy-host.js +++ b/backend/internal/proxy-host.js @@ -284,7 +284,7 @@ const internalProxyHost = { .where("is_deleted", 0) .andWhere(castJsonIfNeed("domain_names"), "like", "%" + thisData.domain + "%") .allowGraph("[owner,access_list.[clients,items],certificate]") - .modify(function(queryBuilder) { + .modify((queryBuilder) => { if (thisData.expand) { queryBuilder.withGraphFetched("[" + thisData.expand.join(', ') + "]"); } From f96775e7ac45579145f1161c1ad3ba899eaf931a Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Mon, 17 Nov 2025 12:08:23 -0500 Subject: [PATCH 19/39] added endpoint to query by domain --- backend/internal/proxy-host.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/internal/proxy-host.js b/backend/internal/proxy-host.js index 34fbbc425b..f264f62f99 100644 --- a/backend/internal/proxy-host.js +++ b/backend/internal/proxy-host.js @@ -307,7 +307,7 @@ const internalProxyHost = { } row = internalHost.cleanRowCertificateMeta(row); // Custom omissions - if (typeof thisData.omit !== 'undefined' && thisData.omit !== null) { + if (typeof thisData.omit !== "undefined" && thisData.omit !== null) { row = _.omit(row, thisData.omit); } return row; From abaef1bddfa601dad861a035d4f3741a4b2d4c2a Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Mon, 17 Nov 2025 15:21:36 -0500 Subject: [PATCH 20/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index cdd40c747a..bed5bef272 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -119,7 +119,7 @@ router }) /** - * Specific proxy-host by domain + * Specific proxy-host by domain name * * /api/nginx/proxy-hosts/domain/:domain */ @@ -133,7 +133,7 @@ router /** * GET /api/nginx/proxy-hosts/domain/:domain * - * Retrieve a specific proxy-host by domain + * Retrieve a specific proxy-host by domain name */ .get(async (req, res, next) => { try { From 0395a9aecc117106937757527620ee03e25857ef Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Mon, 17 Nov 2025 15:28:36 -0500 Subject: [PATCH 21/39] added endpoint to query by domain --- backend/internal/proxy-host.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/backend/internal/proxy-host.js b/backend/internal/proxy-host.js index f264f62f99..c9c5281aff 100644 --- a/backend/internal/proxy-host.js +++ b/backend/internal/proxy-host.js @@ -40,7 +40,7 @@ const internalProxyHost = { return Promise.all(domain_name_check_promises).then((check_results) => { check_results.map((result) => { if (result.is_taken) { - throw new errs.ValidationError(result.hostname + " is already in use"); + throw new errs.ValidationError(`${result.hostname} is already in use`); } return true; }); @@ -137,7 +137,7 @@ const internalProxyHost = { return Promise.all(domain_name_check_promises).then((check_results) => { check_results.map((result) => { if (result.is_taken) { - throw new errs.ValidationError(result.hostname + " is already in use"); + throw new errs.ValidationError(`${result.hostname} is already in use`); } return true; }); @@ -151,7 +151,7 @@ const internalProxyHost = { if (row.id !== thisData.id) { // Sanity check that something crazy hasn't happened throw new errs.InternalValidationError( - "Proxy Host could not be updated, IDs do not match: " + row.id + " !== " + thisData.id, + `Proxy Host could not be updated, IDs do not match: ${row.id} !== ${thisData.id}`, ); } @@ -248,7 +248,7 @@ const internalProxyHost = { } if (typeof thisData.expand !== "undefined" && thisData.expand !== null) { - query.withGraphFetched("[" + thisData.expand.join(", ") + "]"); + query.withGraphFetched(`[${thisData.expand.join(", ")}]`); } return query.then(utils.omitRow(omissions())); @@ -279,14 +279,14 @@ const internalProxyHost = { return access.can("proxy_hosts:get", thisData.domain) .then((access_data) => { - let query = proxyHostModel + const query = proxyHostModel .query() .where("is_deleted", 0) - .andWhere(castJsonIfNeed("domain_names"), "like", "%" + thisData.domain + "%") + .andWhere(castJsonIfNeed("domain_names"), "like", `%${thisData.domain}%`) .allowGraph("[owner,access_list.[clients,items],certificate]") .modify((queryBuilder) => { if (thisData.expand) { - queryBuilder.withGraphFetched("[" + thisData.expand.join(', ') + "]"); + queryBuilder.withGraphFetched(`[${thisData.expand.join(', ')}]`); } }) .first(); @@ -296,7 +296,7 @@ const internalProxyHost = { } if (typeof thisData.expand !== "undefined" && thisData.expand !== null) { - query.withGraphFetched("[" + thisData.expand.join(', ') + "]"); + query.withGraphFetched(`[${thisData.expand.join(', ')}]`); } return query.then(utils.omitRow(omissions())); @@ -484,12 +484,12 @@ const internalProxyHost = { // Query is used for searching if (typeof searchQuery === "string" && searchQuery.length > 0) { query.where(function () { - this.where(castJsonIfNeed("domain_names"), "like", "%" + searchQuery + "%"); + this.where(castJsonIfNeed("domain_names"), "like", `%${searchQuery}%`); }); } if (typeof expand !== "undefined" && expand !== null) { - query.withGraphFetched("[" + expand.join(", ") + "]"); + query.withGraphFetched(`[${expand.join(", ")}]`); } const rows = await query.then(utils.omitRows(omissions())); From 19284bae2b702c4535dcf5efb0254d78d1932a51 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Mon, 17 Nov 2025 15:31:37 -0500 Subject: [PATCH 22/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 46 ----------------------------- 1 file changed, 46 deletions(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index bed5bef272..353935cd37 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -197,52 +197,6 @@ router } }); -/** - * Specific proxy-host by domain - * - * /api/nginx/proxy-hosts/domain/:domain - */ -router - .route('/domain/:domain') - .options((req, res) => { - res.sendStatus(204); - }) - .all(jwtdecode()) - - /** - * GET /api/nginx/proxy-hosts/domain/:domain - * - * Retrieve a specific proxy-host by domain - */ - .get((req, res, next) => { - validator({ - required: ['domain'], - additionalProperties: false, - properties: { - domain: { - type: 'string' - }, - expand: { - $ref: 'common#/properties/expand' - } - } - }, { - domain: req.params.domain, - expand: (typeof req.query.expand === 'string' ? req.query.expand.split(',') : null) - }) - .then((data) => { - return internalProxyHost.getByDomain(res.locals.access, { - domain: data.domain, - expand: data.expand - }); - }) - .then((row) => { - res.status(200) - .send(row); - }) - .catch(next); - }); - /** * Enable proxy-host * From 4c9fe2600c1bec9ff6997feeaac2c9e9882cfbc9 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Mon, 17 Nov 2025 15:38:05 -0500 Subject: [PATCH 23/39] added endpoint to query by domain --- backend/internal/proxy-host.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/internal/proxy-host.js b/backend/internal/proxy-host.js index c9c5281aff..6cb698a2db 100644 --- a/backend/internal/proxy-host.js +++ b/backend/internal/proxy-host.js @@ -296,21 +296,21 @@ const internalProxyHost = { } if (typeof thisData.expand !== "undefined" && thisData.expand !== null) { - query.withGraphFetched(`[${thisData.expand.join(', ')}]`); + query.withGraphFetched(`[${thisData.expand.join(", ")}]`); } return query.then(utils.omitRow(omissions())); }) .then((row) => { if (!row || !row.id) { - throw new error.ItemNotFoundError(thisData.id); + throw new errs.ItemNotFoundError(thisData.id); } - row = internalHost.cleanRowCertificateMeta(row); + const thisRow = internalHost.cleanRowCertificateMeta(row); // Custom omissions if (typeof thisData.omit !== "undefined" && thisData.omit !== null) { - row = _.omit(row, thisData.omit); + return _.omit(row, thisData.omit); } - return row; + return thisRow; }); }, From af0fb995544ad2d44936f54b775687385731048f Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Tue, 18 Nov 2025 08:21:07 -0500 Subject: [PATCH 24/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index 353935cd37..1c42a90528 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -119,7 +119,7 @@ router }) /** - * Specific proxy-host by domain name + * Specific proxy-host by domain * * /api/nginx/proxy-hosts/domain/:domain */ @@ -133,7 +133,7 @@ router /** * GET /api/nginx/proxy-hosts/domain/:domain * - * Retrieve a specific proxy-host by domain name + * Retrieve a specific proxy-host by domain */ .get(async (req, res, next) => { try { From a448dbebab506998d012c434d967589f5e7fbfad Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Tue, 18 Nov 2025 12:39:53 -0500 Subject: [PATCH 25/39] added endpoint to query by domain --- backend/internal/proxy-host.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/internal/proxy-host.js b/backend/internal/proxy-host.js index 6cb698a2db..e8a2faf27b 100644 --- a/backend/internal/proxy-host.js +++ b/backend/internal/proxy-host.js @@ -282,7 +282,7 @@ const internalProxyHost = { const query = proxyHostModel .query() .where("is_deleted", 0) - .andWhere(castJsonIfNeed("domain_names"), "like", `%${thisData.domain}%`) + .andWhereRaw("domain_names::jsonb @> ?::jsonb", [JSON.stringify([thisData.domain])]) .allowGraph("[owner,access_list.[clients,items],certificate]") .modify((queryBuilder) => { if (thisData.expand) { From 4e2e85ba915a75cb811c06c14ab855b30fb43b9d Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Tue, 18 Nov 2025 12:45:11 -0500 Subject: [PATCH 26/39] added endpoint to query by domain --- backend/internal/proxy-host.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/internal/proxy-host.js b/backend/internal/proxy-host.js index e8a2faf27b..6cb698a2db 100644 --- a/backend/internal/proxy-host.js +++ b/backend/internal/proxy-host.js @@ -282,7 +282,7 @@ const internalProxyHost = { const query = proxyHostModel .query() .where("is_deleted", 0) - .andWhereRaw("domain_names::jsonb @> ?::jsonb", [JSON.stringify([thisData.domain])]) + .andWhere(castJsonIfNeed("domain_names"), "like", `%${thisData.domain}%`) .allowGraph("[owner,access_list.[clients,items],certificate]") .modify((queryBuilder) => { if (thisData.expand) { From 816556823b88ab533c213eda7a0cdf621a3d6f24 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Tue, 18 Nov 2025 12:53:59 -0500 Subject: [PATCH 27/39] added endpoint to query by domain --- backend/internal/proxy-host.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/backend/internal/proxy-host.js b/backend/internal/proxy-host.js index 6cb698a2db..836d605c2f 100644 --- a/backend/internal/proxy-host.js +++ b/backend/internal/proxy-host.js @@ -284,11 +284,6 @@ const internalProxyHost = { .where("is_deleted", 0) .andWhere(castJsonIfNeed("domain_names"), "like", `%${thisData.domain}%`) .allowGraph("[owner,access_list.[clients,items],certificate]") - .modify((queryBuilder) => { - if (thisData.expand) { - queryBuilder.withGraphFetched(`[${thisData.expand.join(', ')}]`); - } - }) .first(); if (access_data.permission_visibility !== "all") { From 00afc5070daaa0c287f88d1978baa17c6723e3f6 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Tue, 18 Nov 2025 13:44:56 -0500 Subject: [PATCH 28/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index 1c42a90528..6dc19f8001 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -152,7 +152,7 @@ router domain: req.params.domain, expand: (typeof req.query.expand === "string" ? req.query.expand.split(",") : null) }); - const row = internalProxyHost.getByDomain(res.locals.access, { + const row = await internalProxyHost.getByDomain(res.locals.access, { domain: data.domain, expand: data.expand }); From e19b0a927e304e0568fb524c238b54291535c05c Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Tue, 18 Nov 2025 14:20:54 -0500 Subject: [PATCH 29/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index 6dc19f8001..75f466c074 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -119,7 +119,7 @@ router }) /** - * Specific proxy-host by domain + * Specific proxy-host by domain name * * /api/nginx/proxy-hosts/domain/:domain */ @@ -133,7 +133,7 @@ router /** * GET /api/nginx/proxy-hosts/domain/:domain * - * Retrieve a specific proxy-host by domain + * Retrieve a specific proxy-host by domain name */ .get(async (req, res, next) => { try { From 97245fa90ac6b8fee905a06c6205c43c3df921e1 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Tue, 18 Nov 2025 15:11:27 -0500 Subject: [PATCH 30/39] added endpoint to query by domain --- backend/internal/proxy-host.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/internal/proxy-host.js b/backend/internal/proxy-host.js index 836d605c2f..2a08373502 100644 --- a/backend/internal/proxy-host.js +++ b/backend/internal/proxy-host.js @@ -282,7 +282,7 @@ const internalProxyHost = { const query = proxyHostModel .query() .where("is_deleted", 0) - .andWhere(castJsonIfNeed("domain_names"), "like", `%${thisData.domain}%`) + .whereJsonSupersetOf("domain_names", [thisData.domain]) .allowGraph("[owner,access_list.[clients,items],certificate]") .first(); From ac164347fc1de90991422b2b6d1ce169dfff6cca Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Tue, 18 Nov 2025 15:18:05 -0500 Subject: [PATCH 31/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index 75f466c074..6dc19f8001 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -119,7 +119,7 @@ router }) /** - * Specific proxy-host by domain name + * Specific proxy-host by domain * * /api/nginx/proxy-hosts/domain/:domain */ @@ -133,7 +133,7 @@ router /** * GET /api/nginx/proxy-hosts/domain/:domain * - * Retrieve a specific proxy-host by domain name + * Retrieve a specific proxy-host by domain */ .get(async (req, res, next) => { try { From d0ae14bbb7b97d39631bf0a9bc66bc7df87adb94 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Wed, 19 Nov 2025 02:36:02 -0500 Subject: [PATCH 32/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index 6dc19f8001..75f466c074 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -119,7 +119,7 @@ router }) /** - * Specific proxy-host by domain + * Specific proxy-host by domain name * * /api/nginx/proxy-hosts/domain/:domain */ @@ -133,7 +133,7 @@ router /** * GET /api/nginx/proxy-hosts/domain/:domain * - * Retrieve a specific proxy-host by domain + * Retrieve a specific proxy-host by domain name */ .get(async (req, res, next) => { try { From db6728c8c8f21e759c6baa75c4cf249b7714cbf1 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Wed, 19 Nov 2025 02:42:15 -0500 Subject: [PATCH 33/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index 75f466c074..6dc19f8001 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -119,7 +119,7 @@ router }) /** - * Specific proxy-host by domain name + * Specific proxy-host by domain * * /api/nginx/proxy-hosts/domain/:domain */ @@ -133,7 +133,7 @@ router /** * GET /api/nginx/proxy-hosts/domain/:domain * - * Retrieve a specific proxy-host by domain name + * Retrieve a specific proxy-host by domain */ .get(async (req, res, next) => { try { From be6cdbf61525bbf6dcef5dfc45236ed63d826dd7 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Wed, 19 Nov 2025 08:26:52 -0500 Subject: [PATCH 34/39] added endpoint to query by domain --- backend/internal/proxy-host.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/internal/proxy-host.js b/backend/internal/proxy-host.js index 2a08373502..9dfabecabf 100644 --- a/backend/internal/proxy-host.js +++ b/backend/internal/proxy-host.js @@ -282,7 +282,7 @@ const internalProxyHost = { const query = proxyHostModel .query() .where("is_deleted", 0) - .whereJsonSupersetOf("domain_names", [thisData.domain]) + .andWhere(castJsonIfNeed("domain_names"), "like", `%"${thisData.domain}"%`) .allowGraph("[owner,access_list.[clients,items],certificate]") .first(); From 3ac3d2c42a31a570765cbeaf0eaec26c6c5d6acb Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Wed, 19 Nov 2025 08:29:25 -0500 Subject: [PATCH 35/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index 6dc19f8001..75f466c074 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -119,7 +119,7 @@ router }) /** - * Specific proxy-host by domain + * Specific proxy-host by domain name * * /api/nginx/proxy-hosts/domain/:domain */ @@ -133,7 +133,7 @@ router /** * GET /api/nginx/proxy-hosts/domain/:domain * - * Retrieve a specific proxy-host by domain + * Retrieve a specific proxy-host by domain name */ .get(async (req, res, next) => { try { From 96912376c8aefd6d521b469f5a34dcdf2d4ba8ef Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Wed, 19 Nov 2025 08:54:55 -0500 Subject: [PATCH 36/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index 75f466c074..6dc19f8001 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -119,7 +119,7 @@ router }) /** - * Specific proxy-host by domain name + * Specific proxy-host by domain * * /api/nginx/proxy-hosts/domain/:domain */ @@ -133,7 +133,7 @@ router /** * GET /api/nginx/proxy-hosts/domain/:domain * - * Retrieve a specific proxy-host by domain name + * Retrieve a specific proxy-host by domain */ .get(async (req, res, next) => { try { From ca39379b981cc279546dcf7bf1da21746ae070d8 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Wed, 19 Nov 2025 09:01:15 -0500 Subject: [PATCH 37/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index 6dc19f8001..75f466c074 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -119,7 +119,7 @@ router }) /** - * Specific proxy-host by domain + * Specific proxy-host by domain name * * /api/nginx/proxy-hosts/domain/:domain */ @@ -133,7 +133,7 @@ router /** * GET /api/nginx/proxy-hosts/domain/:domain * - * Retrieve a specific proxy-host by domain + * Retrieve a specific proxy-host by domain name */ .get(async (req, res, next) => { try { From 92ceec84c50cc0fb6bae129eb3ea8e926f9d7855 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Fri, 21 Nov 2025 09:09:17 -0500 Subject: [PATCH 38/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 90 ++++++++++++++--------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index 75f466c074..b3b2ae4c72 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -118,51 +118,6 @@ router } }) -/** - * Specific proxy-host by domain name - * - * /api/nginx/proxy-hosts/domain/:domain - */ -router - .route("/domain/:domain") - .options((_, res) => { - res.sendStatus(204); - }) - .all(jwtdecode()) - - /** - * GET /api/nginx/proxy-hosts/domain/:domain - * - * Retrieve a specific proxy-host by domain name - */ - .get(async (req, res, next) => { - try { - const data = await validator({ - required: ["domain"], - additionalProperties: false, - properties: { - domain: { - type: "string", - }, - expand: { - $ref: "common#/properties/expand" - } - } - }, { - domain: req.params.domain, - expand: (typeof req.query.expand === "string" ? req.query.expand.split(",") : null) - }); - const row = await internalProxyHost.getByDomain(res.locals.access, { - domain: data.domain, - expand: data.expand - }); - res.status(200).send(row); - } catch (err) { - debug(logger, `${req.method.toUpperCase()} ${req.path}: ${err}`); - next(err); - } - }) - /** * PUT /api/nginx/proxy-hosts/123 * @@ -251,4 +206,49 @@ router } }); +/** + * Specific proxy-host by domain name + * + * /api/nginx/proxy-hosts/domain/:domain + */ +router + .route("/domain/:domain") + .options((_, res) => { + res.sendStatus(204); + }) + .all(jwtdecode()) + + /** + * GET /api/nginx/proxy-hosts/domain/:domain + * + * Retrieve a specific proxy-host by domain name + */ + .get(async (req, res, next) => { + try { + const data = await validator({ + required: ["domain"], + additionalProperties: false, + properties: { + domain: { + type: "string", + }, + expand: { + $ref: "common#/properties/expand" + } + } + }, { + domain: req.params.domain, + expand: (typeof req.query.expand === "string" ? req.query.expand.split(",") : null) + }); + const row = await internalProxyHost.getByDomain(res.locals.access, { + domain: data.domain, + expand: data.expand + }); + res.status(200).send(row); + } catch (err) { + debug(logger, `${req.method.toUpperCase()} ${req.path}: ${err}`); + next(err); + } + }) + export default router; From 5b85760772e45e7a2789130312feaf9cc50c6586 Mon Sep 17 00:00:00 2001 From: code-a-cola <26146122+code-a-cola@users.noreply.github.com> Date: Fri, 21 Nov 2025 09:50:53 -0500 Subject: [PATCH 39/39] added endpoint to query by domain --- backend/routes/nginx/proxy_hosts.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/backend/routes/nginx/proxy_hosts.js b/backend/routes/nginx/proxy_hosts.js index b3b2ae4c72..60ba23873e 100644 --- a/backend/routes/nginx/proxy_hosts.js +++ b/backend/routes/nginx/proxy_hosts.js @@ -207,7 +207,7 @@ router }); /** - * Specific proxy-host by domain name + * Specific proxy-host by domain * * /api/nginx/proxy-hosts/domain/:domain */ @@ -220,8 +220,6 @@ router /** * GET /api/nginx/proxy-hosts/domain/:domain - * - * Retrieve a specific proxy-host by domain name */ .get(async (req, res, next) => { try { @@ -249,6 +247,6 @@ router debug(logger, `${req.method.toUpperCase()} ${req.path}: ${err}`); next(err); } - }) + }); export default router;