0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 16:22:44 +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
const templateFn = require('./../client/template.js');
app.use(asyncHandler(async (req, res, next)=>{
const renderPage = async (req, res) => {
// Create configuration object
const configuration = {
local : isLocalEnvironment,
@@ -449,6 +448,11 @@ app.use(asyncHandler(async (req, res, next)=>{
console.log(err);
return res.sendStatus(500);
});
return page;
};
app.use(asyncHandler(async (req, res, next)=>{
const page = await renderPage(req, res);
if(!page) return;
res.send(page);
}));