✨feature: Incorporate new sites routes, add dummy favicon to stop 404 errors
This commit is contained in:
@@ -37,6 +37,31 @@ 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/:domain', async function (req, res, next) {
|
||||
const domainName = req.params.domain;
|
||||
let sites = null;
|
||||
|
||||
try {
|
||||
sites = 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);
|
||||
}
|
||||
|
||||
console.log('Site found:', sites);
|
||||
|
||||
if (!sites || sites.length === 0) {
|
||||
return res.status(404).send('Site not found');
|
||||
} else {
|
||||
res.json(sites[0]); // Return the first match
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* POST create a new site.
|
||||
*
|
||||
@@ -59,7 +84,7 @@ router.post('/add', async function (req, res, next) {
|
||||
if (!newSite) {
|
||||
res.status(400).send('Error creating site');
|
||||
} else {
|
||||
res.redirect('/'); // status 304
|
||||
res.status(201).json(newSite);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user