0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-06 20:52:40 +00:00

Break out page rendering into function

This commit is contained in:
Trevor Buckner
2023-06-23 16:29:17 -04:00
parent e07d53aa5f
commit 2fa1b2bb8b

View File

@@ -423,8 +423,7 @@ if(isLocalEnvironment){
//Render the page //Render the page
const templateFn = require('./../client/template.js'); const templateFn = require('./../client/template.js');
app.use(asyncHandler(async (req, res, next)=>{ const renderPage = async (req, res) => {
// Create configuration object // Create configuration object
const configuration = { const configuration = {
local : isLocalEnvironment, local : isLocalEnvironment,
@@ -449,6 +448,11 @@ app.use(asyncHandler(async (req, res, next)=>{
console.log(err); console.log(err);
return res.sendStatus(500); return res.sendStatus(500);
}); });
return page;
};
app.use(asyncHandler(async (req, res, next)=>{
const page = await renderPage(req, res);
if(!page) return; if(!page) return;
res.send(page); res.send(page);
})); }));