Remove name from insert method - this is removed from db schema

This commit is contained in:
Aarish
2025-05-25 17:06:37 -05:00
parent b9967a8e66
commit f28328dcc4
2 changed files with 26 additions and 4 deletions

View File

@@ -37,6 +37,29 @@ router.get('/:id', async function(req, res, next) {
}
});
/**
* GET site by domain name.
*
* Returns a specific site by its domain name in JSON format.
*/
router.get('/:domain', async function(req, res, next) {
const domainName = req.params.domain;
let site = null;
try {
site = await siteModel.getByDomainName(domainName);
} catch (error) {
console.error('Error fetching site by domain name:', error);
return res.status(400).send('Error fetching site: ' + error.message);
}
if (!site || site.length === 0) {
return res.status(404).send('Site not found');
} else {
res.json(site[0]); // Return the first match
}
});
/**
* POST create a new site.
*
@@ -50,7 +73,7 @@ router.post('/add', async function(req, res, next) {
// insert method passes a lot of validation errors to the caller
try {
newSite = await siteModel.insert(domain, domain);
newSite = await siteModel.insert(domain);
} catch (error) {
console.error('Error creating site:', error);
return res.status(400).send('Error creating site: ' + error.message);