Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added endpoint to query by domain
  • Loading branch information
code-a-cola committed Apr 25, 2025
commit 8178951ff7fa16f81f71c228f29405ebf00f3ce4
70 changes: 58 additions & 12 deletions backend/routes/nginx/proxy_hosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
})
Expand All @@ -158,7 +158,7 @@ router
.send(row);
})
.catch(next);
});
})

/**
* PUT /api/nginx/proxy-hosts/123
Expand Down Expand Up @@ -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
*
Expand Down