0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-04 16:52:38 +00:00

from admin to archive api

This commit is contained in:
Víctor Losada Hernández
2024-01-23 10:40:53 +01:00
parent 0dff59d793
commit 54a2f6940c
4 changed files with 46 additions and 89 deletions

View File

@@ -67,6 +67,7 @@ app.use((req, res, next)=>{
app.use(homebrewApi);
app.use(require('./admin.api.js'));
app.use(require('./archive.api.js'));
const HomebrewModel = require('./homebrew.model.js').model;
const welcomeText = require('fs').readFileSync('client/homebrew/pages/homePage/welcome_msg.md', 'utf8');
@@ -480,6 +481,11 @@ app.use(async (err, req, res, next)=>{
res.status(err.status || err.response?.status || 500).send(err);
return;
}
if(err.originalUrl?.startsWith('/archive/')) {
// console.log('archive error');
res.status(err.status || err.response?.status || 500).send(err);
return;
}
// console.log('non-API error');
const status = err.status || err.code || 500;
@@ -503,6 +509,8 @@ app.use(async (err, req, res, next)=>{
res.send(page);
});
app.use((req, res)=>{
if(!res.headersSent) {
console.error('Headers have not been sent, responding with a server error.', req.url);