0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-27 11:32:38 +00:00

linting and remove async conflict

This commit is contained in:
Víctor Losada Hernández
2024-05-07 10:14:46 +02:00
parent 40ac8b1909
commit f9f2e604c0
2 changed files with 353 additions and 295 deletions

View File

@@ -8,12 +8,18 @@ const archive = {
findBrews: async (req, res, next) => {
try {
/*
//log db name and collection name, for local purposes
const dbName = HomebrewModel.db.name;
console.log("Database Name:", dbName);
const collectionName = HomebrewModel.collection.name;
console.log("Collection Name:", collectionName);
*/
const bright = '\x1b[1m'; // Bright (bold) style
const yellow = '\x1b[93m'; // yellow color
const reset = '\x1b[0m'; // Reset to default style
console.log(`Query as received in ${bright + yellow}archive api${reset}:`);
console.table(req.query);
const title = req.query.title || '';
@@ -88,11 +94,26 @@ const archive = {
return res.json({ brews, page, totalPages, totalBrews });
} catch (error) {
console.error(error);
console.log('error status number: ', error.response.status);
if (error.response && error.response.status === 503) {
return res
.status(503)
.json({ errorCode: '503', message: 'Service Unavailable' });
if (error.response && error.response.status) {
const status = error.response.status;
if (status === 500) {
return res.status(500).json({
errorCode: '500',
message: 'Internal Server Error',
});
} else if (status === 503) {
return res.status(503).json({
errorCode: '503',
message: 'Service Unavailable',
});
} else {
return res.status(status).json({
errorCode: status.toString(),
message: 'Internal Server Error',
});
}
} else {
return res.status(500).json({
errorCode: '500',