Linting
parent
a4e0f03b70
commit
e68be9aa14
137
routes/index.js
137
routes/index.js
|
@ -3,7 +3,19 @@ const router = express.Router();
|
||||||
const colors = require('colors');
|
const colors = require('colors');
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const common = require('../lib/common');
|
const {
|
||||||
|
getId,
|
||||||
|
hooker,
|
||||||
|
showCartCloseBtn,
|
||||||
|
clearSessionValue,
|
||||||
|
sortMenu,
|
||||||
|
getMenu,
|
||||||
|
getPaymentConfig,
|
||||||
|
getImages,
|
||||||
|
updateTotalCartAmount,
|
||||||
|
getData,
|
||||||
|
addSitemapProducts
|
||||||
|
} = require('../lib/common');
|
||||||
|
|
||||||
// These is the customer facing routes
|
// These is the customer facing routes
|
||||||
router.get('/payment/:orderId', async (req, res, next) => {
|
router.get('/payment/:orderId', async (req, res, next) => {
|
||||||
|
@ -11,7 +23,7 @@ router.get('/payment/:orderId', async (req, res, next) => {
|
||||||
let config = req.app.config;
|
let config = req.app.config;
|
||||||
|
|
||||||
// render the payment complete message
|
// render the payment complete message
|
||||||
db.orders.findOne({ _id: common.getId(req.params.orderId) }, async (err, order) => {
|
db.orders.findOne({ _id: getId(req.params.orderId) }, async (err, order) => {
|
||||||
if(err){
|
if(err){
|
||||||
console.info(err.stack);
|
console.info(err.stack);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +31,7 @@ router.get('/payment/:orderId', async (req, res, next) => {
|
||||||
// If stock management is turned on payment approved update stock level
|
// If stock management is turned on payment approved update stock level
|
||||||
if(config.trackStock && req.session.paymentApproved){
|
if(config.trackStock && req.session.paymentApproved){
|
||||||
order.orderProducts.forEach(async (product) => {
|
order.orderProducts.forEach(async (product) => {
|
||||||
const dbProduct = await db.products.findOne({ _id: common.getId(product.productId) });
|
const dbProduct = await db.products.findOne({ _id: getId(product.productId) });
|
||||||
let newStockLevel = dbProduct.productStock - product.quantity;
|
let newStockLevel = dbProduct.productStock - product.quantity;
|
||||||
if(newStockLevel < 1){
|
if(newStockLevel < 1){
|
||||||
newStockLevel = 0;
|
newStockLevel = 0;
|
||||||
|
@ -27,7 +39,7 @@ router.get('/payment/:orderId', async (req, res, next) => {
|
||||||
|
|
||||||
// Update product stock
|
// Update product stock
|
||||||
await db.products.update({
|
await db.products.update({
|
||||||
_id: common.getId(product.productId)
|
_id: getId(product.productId)
|
||||||
}, {
|
}, {
|
||||||
$set: {
|
$set: {
|
||||||
productStock: newStockLevel
|
productStock: newStockLevel
|
||||||
|
@ -36,17 +48,22 @@ router.get('/payment/:orderId', async (req, res, next) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If hooks are configured, send hook
|
||||||
|
if(config.orderHook){
|
||||||
|
await hooker(order);
|
||||||
|
};
|
||||||
|
|
||||||
res.render(`${config.themeViews}payment_complete`, {
|
res.render(`${config.themeViews}payment_complete`, {
|
||||||
title: 'Payment complete',
|
title: 'Payment complete',
|
||||||
config: req.app.config,
|
config: req.app.config,
|
||||||
session: req.session,
|
session: req.session,
|
||||||
pageCloseBtn: common.showCartCloseBtn('payment'),
|
pageCloseBtn: showCartCloseBtn('payment'),
|
||||||
result: order,
|
result: order,
|
||||||
message: common.clearSessionValue(req.session, 'message'),
|
message: clearSessionValue(req.session, 'message'),
|
||||||
messageType: common.clearSessionValue(req.session, 'messageType'),
|
messageType: clearSessionValue(req.session, 'messageType'),
|
||||||
helpers: req.handlebars.helpers,
|
helpers: req.handlebars.helpers,
|
||||||
showFooter: 'showFooter',
|
showFooter: 'showFooter',
|
||||||
menu: common.sortMenu(await common.getMenu(db))
|
menu: sortMenu(await getMenu(db))
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -67,11 +84,11 @@ router.get('/checkout', async (req, res, next) => {
|
||||||
title: 'Checkout',
|
title: 'Checkout',
|
||||||
config: req.app.config,
|
config: req.app.config,
|
||||||
session: req.session,
|
session: req.session,
|
||||||
pageCloseBtn: common.showCartCloseBtn('checkout'),
|
pageCloseBtn: showCartCloseBtn('checkout'),
|
||||||
checkout: 'hidden',
|
checkout: 'hidden',
|
||||||
page: 'checkout',
|
page: 'checkout',
|
||||||
message: common.clearSessionValue(req.session, 'message'),
|
message: clearSessionValue(req.session, 'message'),
|
||||||
messageType: common.clearSessionValue(req.session, 'messageType'),
|
messageType: clearSessionValue(req.session, 'messageType'),
|
||||||
helpers: req.handlebars.helpers,
|
helpers: req.handlebars.helpers,
|
||||||
showFooter: 'showFooter'
|
showFooter: 'showFooter'
|
||||||
});
|
});
|
||||||
|
@ -92,13 +109,13 @@ router.get('/pay', async (req, res, next) => {
|
||||||
res.render(`${config.themeViews}pay`, {
|
res.render(`${config.themeViews}pay`, {
|
||||||
title: 'Pay',
|
title: 'Pay',
|
||||||
config: req.app.config,
|
config: req.app.config,
|
||||||
paymentConfig: common.getPaymentConfig(),
|
paymentConfig: getPaymentConfig(),
|
||||||
pageCloseBtn: common.showCartCloseBtn('pay'),
|
pageCloseBtn: showCartCloseBtn('pay'),
|
||||||
session: req.session,
|
session: req.session,
|
||||||
paymentPage: true,
|
paymentPage: true,
|
||||||
page: 'pay',
|
page: 'pay',
|
||||||
message: common.clearSessionValue(req.session, 'message'),
|
message: clearSessionValue(req.session, 'message'),
|
||||||
messageType: common.clearSessionValue(req.session, 'messageType'),
|
messageType: clearSessionValue(req.session, 'messageType'),
|
||||||
helpers: req.handlebars.helpers,
|
helpers: req.handlebars.helpers,
|
||||||
showFooter: 'showFooter'
|
showFooter: 'showFooter'
|
||||||
});
|
});
|
||||||
|
@ -108,7 +125,7 @@ router.get('/cartPartial', (req, res) => {
|
||||||
const config = req.app.config;
|
const config = req.app.config;
|
||||||
|
|
||||||
res.render(`${config.themeViews}cart`, {
|
res.render(`${config.themeViews}cart`, {
|
||||||
pageCloseBtn: common.showCartCloseBtn(req.query.path),
|
pageCloseBtn: showCartCloseBtn(req.query.path),
|
||||||
page: req.query.path,
|
page: req.query.path,
|
||||||
layout: false,
|
layout: false,
|
||||||
helpers: req.handlebars.helpers,
|
helpers: req.handlebars.helpers,
|
||||||
|
@ -122,7 +139,7 @@ router.get('/product/:id', (req, res) => {
|
||||||
let db = req.app.db;
|
let db = req.app.db;
|
||||||
let config = req.app.config;
|
let config = req.app.config;
|
||||||
|
|
||||||
db.products.findOne({ $or: [{ _id: common.getId(req.params.id) }, { productPermalink: req.params.id }] }, (err, result) => {
|
db.products.findOne({ $or: [{ _id: getId(req.params.id) }, { productPermalink: req.params.id }] }, (err, result) => {
|
||||||
// render 404 if page is not published
|
// render 404 if page is not published
|
||||||
if(err){
|
if(err){
|
||||||
res.render('error', { title: 'Not found', message: 'Product not found', helpers: req.handlebars.helpers, config });
|
res.render('error', { title: 'Not found', message: 'Product not found', helpers: req.handlebars.helpers, config });
|
||||||
|
@ -142,7 +159,7 @@ router.get('/product/:id', (req, res) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// show the view
|
// show the view
|
||||||
common.getImages(result._id, req, res, async (images) => {
|
getImages(result._id, req, res, async (images) => {
|
||||||
res.render(`${config.themeViews}product`, {
|
res.render(`${config.themeViews}product`, {
|
||||||
title: result.productTitle,
|
title: result.productTitle,
|
||||||
result: result,
|
result: result,
|
||||||
|
@ -150,15 +167,15 @@ router.get('/product/:id', (req, res) => {
|
||||||
images: images,
|
images: images,
|
||||||
productDescription: result.productDescription,
|
productDescription: result.productDescription,
|
||||||
metaDescription: config.cartTitle + ' - ' + result.productTitle,
|
metaDescription: config.cartTitle + ' - ' + result.productTitle,
|
||||||
pageCloseBtn: common.showCartCloseBtn('product'),
|
pageCloseBtn: showCartCloseBtn('product'),
|
||||||
config: config,
|
config: config,
|
||||||
session: req.session,
|
session: req.session,
|
||||||
pageUrl: config.baseUrl + req.originalUrl,
|
pageUrl: config.baseUrl + req.originalUrl,
|
||||||
message: common.clearSessionValue(req.session, 'message'),
|
message: clearSessionValue(req.session, 'message'),
|
||||||
messageType: common.clearSessionValue(req.session, 'messageType'),
|
messageType: clearSessionValue(req.session, 'messageType'),
|
||||||
helpers: req.handlebars.helpers,
|
helpers: req.handlebars.helpers,
|
||||||
showFooter: 'showFooter',
|
showFooter: 'showFooter',
|
||||||
menu: common.sortMenu(await common.getMenu(db))
|
menu: sortMenu(await getMenu(db))
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -180,7 +197,7 @@ router.post('/product/updatecart', (req, res, next) => {
|
||||||
req.session.cart.splice(cartItem.cartIndex, 1);
|
req.session.cart.splice(cartItem.cartIndex, 1);
|
||||||
callback(null);
|
callback(null);
|
||||||
}else{
|
}else{
|
||||||
db.products.findOne({ _id: common.getId(cartItem.productId) }, (err, product) => {
|
db.products.findOne({ _id: getId(cartItem.productId) }, (err, product) => {
|
||||||
if(err){
|
if(err){
|
||||||
console.error(colors.red('Error updating cart', err));
|
console.error(colors.red('Error updating cart', err));
|
||||||
}
|
}
|
||||||
|
@ -209,7 +226,7 @@ router.post('/product/updatecart', (req, res, next) => {
|
||||||
}
|
}
|
||||||
}, async () => {
|
}, async () => {
|
||||||
// update total cart amount
|
// update total cart amount
|
||||||
common.updateTotalCartAmount(req, res);
|
updateTotalCartAmount(req, res);
|
||||||
|
|
||||||
// Update cart to the DB
|
// Update cart to the DB
|
||||||
await db.cart.update({ sessionId: req.session.id }, {
|
await db.cart.update({ sessionId: req.session.id }, {
|
||||||
|
@ -249,7 +266,7 @@ router.post('/product/removefromcart', (req, res, next) => {
|
||||||
$set: { cart: req.session.cart }
|
$set: { cart: req.session.cart }
|
||||||
});
|
});
|
||||||
// update total cart amount
|
// update total cart amount
|
||||||
common.updateTotalCartAmount(req, res);
|
updateTotalCartAmount(req, res);
|
||||||
|
|
||||||
if(itemRemoved === false){
|
if(itemRemoved === false){
|
||||||
return res.status(400).json({ message: 'Product not found in cart' });
|
return res.status(400).json({ message: 'Product not found in cart' });
|
||||||
|
@ -270,7 +287,7 @@ router.post('/product/emptycart', async (req, res, next) => {
|
||||||
await db.cart.removeOne({ sessionId: req.session.id });
|
await db.cart.removeOne({ sessionId: req.session.id });
|
||||||
|
|
||||||
// update total cart amount
|
// update total cart amount
|
||||||
common.updateTotalCartAmount(req, res);
|
updateTotalCartAmount(req, res);
|
||||||
res.status(200).json({ message: 'Cart successfully emptied', totalCartItems: 0 });
|
res.status(200).json({ message: 'Cart successfully emptied', totalCartItems: 0 });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -292,7 +309,7 @@ router.post('/product/addtocart', (req, res, next) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the item from the DB
|
// Get the item from the DB
|
||||||
db.products.findOne({ _id: common.getId(req.body.productId) }, async (err, product) => {
|
db.products.findOne({ _id: getId(req.body.productId) }, async (err, product) => {
|
||||||
if(err){
|
if(err){
|
||||||
console.error(colors.red('Error adding to cart', err));
|
console.error(colors.red('Error adding to cart', err));
|
||||||
return res.status(400).json({ message: 'Error updating cart. Please try again.' });
|
return res.status(400).json({ message: 'Error updating cart. Please try again.' });
|
||||||
|
@ -388,7 +405,7 @@ router.post('/product/addtocart', (req, res, next) => {
|
||||||
}, { upsert: true });
|
}, { upsert: true });
|
||||||
|
|
||||||
// update total cart amount
|
// update total cart amount
|
||||||
common.updateTotalCartAmount(req, res);
|
updateTotalCartAmount(req, res);
|
||||||
|
|
||||||
// update how many products in the shopping cart
|
// update how many products in the shopping cart
|
||||||
req.session.cartTotalItems = req.session.cart.reduce((a, b) => +a + +b.quantity, 0);
|
req.session.cartTotalItems = req.session.cart.reduce((a, b) => +a + +b.quantity, 0);
|
||||||
|
@ -406,7 +423,7 @@ router.get('/search/:searchTerm/:pageNum?', (req, res) => {
|
||||||
|
|
||||||
let lunrIdArray = [];
|
let lunrIdArray = [];
|
||||||
productsIndex.search(searchTerm).forEach((id) => {
|
productsIndex.search(searchTerm).forEach((id) => {
|
||||||
lunrIdArray.push(common.getId(id.ref));
|
lunrIdArray.push(getId(id.ref));
|
||||||
});
|
});
|
||||||
|
|
||||||
let pageNum = 1;
|
let pageNum = 1;
|
||||||
|
@ -415,8 +432,8 @@ router.get('/search/:searchTerm/:pageNum?', (req, res) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
Promise.all([
|
Promise.all([
|
||||||
common.getData(req, pageNum, { _id: { $in: lunrIdArray } }),
|
getData(req, pageNum, { _id: { $in: lunrIdArray } }),
|
||||||
common.getMenu(db)
|
getMenu(db)
|
||||||
])
|
])
|
||||||
.then(([results, menu]) => {
|
.then(([results, menu]) => {
|
||||||
// If JSON query param return json instead
|
// If JSON query param return json instead
|
||||||
|
@ -432,15 +449,15 @@ router.get('/search/:searchTerm/:pageNum?', (req, res) => {
|
||||||
session: req.session,
|
session: req.session,
|
||||||
metaDescription: req.app.config.cartTitle + ' - Search term: ' + searchTerm,
|
metaDescription: req.app.config.cartTitle + ' - Search term: ' + searchTerm,
|
||||||
searchTerm: searchTerm,
|
searchTerm: searchTerm,
|
||||||
pageCloseBtn: common.showCartCloseBtn('search'),
|
pageCloseBtn: showCartCloseBtn('search'),
|
||||||
message: common.clearSessionValue(req.session, 'message'),
|
message: clearSessionValue(req.session, 'message'),
|
||||||
messageType: common.clearSessionValue(req.session, 'messageType'),
|
messageType: clearSessionValue(req.session, 'messageType'),
|
||||||
productsPerPage: numberProducts,
|
productsPerPage: numberProducts,
|
||||||
totalProductCount: results.totalProducts,
|
totalProductCount: results.totalProducts,
|
||||||
pageNum: pageNum,
|
pageNum: pageNum,
|
||||||
paginateUrl: 'search',
|
paginateUrl: 'search',
|
||||||
config: config,
|
config: config,
|
||||||
menu: common.sortMenu(menu),
|
menu: sortMenu(menu),
|
||||||
helpers: req.handlebars.helpers,
|
helpers: req.handlebars.helpers,
|
||||||
showFooter: 'showFooter'
|
showFooter: 'showFooter'
|
||||||
});
|
});
|
||||||
|
@ -460,7 +477,7 @@ router.get('/category/:cat/:pageNum?', (req, res) => {
|
||||||
|
|
||||||
let lunrIdArray = [];
|
let lunrIdArray = [];
|
||||||
productsIndex.search(searchTerm).forEach((id) => {
|
productsIndex.search(searchTerm).forEach((id) => {
|
||||||
lunrIdArray.push(common.getId(id.ref));
|
lunrIdArray.push(getId(id.ref));
|
||||||
});
|
});
|
||||||
|
|
||||||
let pageNum = 1;
|
let pageNum = 1;
|
||||||
|
@ -469,11 +486,11 @@ router.get('/category/:cat/:pageNum?', (req, res) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
Promise.all([
|
Promise.all([
|
||||||
common.getData(req, pageNum, { _id: { $in: lunrIdArray } }),
|
getData(req, pageNum, { _id: { $in: lunrIdArray } }),
|
||||||
common.getMenu(db)
|
getMenu(db)
|
||||||
])
|
])
|
||||||
.then(([results, menu]) => {
|
.then(([results, menu]) => {
|
||||||
const sortedMenu = common.sortMenu(menu);
|
const sortedMenu = sortMenu(menu);
|
||||||
|
|
||||||
// If JSON query param return json instead
|
// If JSON query param return json instead
|
||||||
if(req.query.json === 'true'){
|
if(req.query.json === 'true'){
|
||||||
|
@ -488,9 +505,9 @@ router.get('/category/:cat/:pageNum?', (req, res) => {
|
||||||
session: req.session,
|
session: req.session,
|
||||||
searchTerm: searchTerm,
|
searchTerm: searchTerm,
|
||||||
metaDescription: req.app.config.cartTitle + ' - Category: ' + searchTerm,
|
metaDescription: req.app.config.cartTitle + ' - Category: ' + searchTerm,
|
||||||
pageCloseBtn: common.showCartCloseBtn('category'),
|
pageCloseBtn: showCartCloseBtn('category'),
|
||||||
message: common.clearSessionValue(req.session, 'message'),
|
message: clearSessionValue(req.session, 'message'),
|
||||||
messageType: common.clearSessionValue(req.session, 'messageType'),
|
messageType: clearSessionValue(req.session, 'messageType'),
|
||||||
productsPerPage: numberProducts,
|
productsPerPage: numberProducts,
|
||||||
totalProductCount: results.totalProducts,
|
totalProductCount: results.totalProducts,
|
||||||
pageNum: pageNum,
|
pageNum: pageNum,
|
||||||
|
@ -512,7 +529,7 @@ router.get('/sitemap.xml', (req, res, next) => {
|
||||||
let sm = require('sitemap');
|
let sm = require('sitemap');
|
||||||
let config = req.app.config;
|
let config = req.app.config;
|
||||||
|
|
||||||
common.addSitemapProducts(req, res, (err, products) => {
|
addSitemapProducts(req, res, (err, products) => {
|
||||||
if(err){
|
if(err){
|
||||||
console.error(colors.red('Error generating sitemap.xml', err));
|
console.error(colors.red('Error generating sitemap.xml', err));
|
||||||
}
|
}
|
||||||
|
@ -546,8 +563,8 @@ router.get('/page/:pageNum', (req, res, next) => {
|
||||||
let numberProducts = config.productsPerPage ? config.productsPerPage : 6;
|
let numberProducts = config.productsPerPage ? config.productsPerPage : 6;
|
||||||
|
|
||||||
Promise.all([
|
Promise.all([
|
||||||
common.getData(req, req.params.pageNum),
|
getData(req, req.params.pageNum),
|
||||||
common.getMenu(db)
|
getMenu(db)
|
||||||
])
|
])
|
||||||
.then(([results, menu]) => {
|
.then(([results, menu]) => {
|
||||||
// If JSON query param return json instead
|
// If JSON query param return json instead
|
||||||
|
@ -560,10 +577,10 @@ router.get('/page/:pageNum', (req, res, next) => {
|
||||||
title: 'Shop',
|
title: 'Shop',
|
||||||
results: results.data,
|
results: results.data,
|
||||||
session: req.session,
|
session: req.session,
|
||||||
message: common.clearSessionValue(req.session, 'message'),
|
message: clearSessionValue(req.session, 'message'),
|
||||||
messageType: common.clearSessionValue(req.session, 'messageType'),
|
messageType: clearSessionValue(req.session, 'messageType'),
|
||||||
metaDescription: req.app.config.cartTitle + ' - Products page: ' + req.params.pageNum,
|
metaDescription: req.app.config.cartTitle + ' - Products page: ' + req.params.pageNum,
|
||||||
pageCloseBtn: common.showCartCloseBtn('page'),
|
pageCloseBtn: showCartCloseBtn('page'),
|
||||||
config: req.app.config,
|
config: req.app.config,
|
||||||
productsPerPage: numberProducts,
|
productsPerPage: numberProducts,
|
||||||
totalProductCount: results.totalProducts,
|
totalProductCount: results.totalProducts,
|
||||||
|
@ -571,7 +588,7 @@ router.get('/page/:pageNum', (req, res, next) => {
|
||||||
paginateUrl: 'page',
|
paginateUrl: 'page',
|
||||||
helpers: req.handlebars.helpers,
|
helpers: req.handlebars.helpers,
|
||||||
showFooter: 'showFooter',
|
showFooter: 'showFooter',
|
||||||
menu: common.sortMenu(menu)
|
menu: sortMenu(menu)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
@ -588,8 +605,8 @@ router.get('/:page?', (req, res, next) => {
|
||||||
// if no page is specified, just render page 1 of the cart
|
// if no page is specified, just render page 1 of the cart
|
||||||
if(!req.params.page){
|
if(!req.params.page){
|
||||||
Promise.all([
|
Promise.all([
|
||||||
common.getData(req, 1, {}),
|
getData(req, 1, {}),
|
||||||
common.getMenu(db)
|
getMenu(db)
|
||||||
])
|
])
|
||||||
.then(([results, menu]) => {
|
.then(([results, menu]) => {
|
||||||
// If JSON query param return json instead
|
// If JSON query param return json instead
|
||||||
|
@ -603,9 +620,9 @@ router.get('/:page?', (req, res, next) => {
|
||||||
theme: config.theme,
|
theme: config.theme,
|
||||||
results: results.data,
|
results: results.data,
|
||||||
session: req.session,
|
session: req.session,
|
||||||
message: common.clearSessionValue(req.session, 'message'),
|
message: clearSessionValue(req.session, 'message'),
|
||||||
messageType: common.clearSessionValue(req.session, 'messageType'),
|
messageType: clearSessionValue(req.session, 'messageType'),
|
||||||
pageCloseBtn: common.showCartCloseBtn('page'),
|
pageCloseBtn: showCartCloseBtn('page'),
|
||||||
config: req.app.config,
|
config: req.app.config,
|
||||||
productsPerPage: numberProducts,
|
productsPerPage: numberProducts,
|
||||||
totalProductCount: results.totalProducts,
|
totalProductCount: results.totalProducts,
|
||||||
|
@ -613,7 +630,7 @@ router.get('/:page?', (req, res, next) => {
|
||||||
paginateUrl: 'page',
|
paginateUrl: 'page',
|
||||||
helpers: req.handlebars.helpers,
|
helpers: req.handlebars.helpers,
|
||||||
showFooter: 'showFooter',
|
showFooter: 'showFooter',
|
||||||
menu: common.sortMenu(menu)
|
menu: sortMenu(menu)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
@ -636,14 +653,14 @@ router.get('/:page?', (req, res, next) => {
|
||||||
page: page,
|
page: page,
|
||||||
searchTerm: req.params.page,
|
searchTerm: req.params.page,
|
||||||
session: req.session,
|
session: req.session,
|
||||||
message: common.clearSessionValue(req.session, 'message'),
|
message: clearSessionValue(req.session, 'message'),
|
||||||
messageType: common.clearSessionValue(req.session, 'messageType'),
|
messageType: clearSessionValue(req.session, 'messageType'),
|
||||||
pageCloseBtn: common.showCartCloseBtn('page'),
|
pageCloseBtn: showCartCloseBtn('page'),
|
||||||
config: req.app.config,
|
config: req.app.config,
|
||||||
metaDescription: req.app.config.cartTitle + ' - ' + page,
|
metaDescription: req.app.config.cartTitle + ' - ' + page,
|
||||||
helpers: req.handlebars.helpers,
|
helpers: req.handlebars.helpers,
|
||||||
showFooter: 'showFooter',
|
showFooter: 'showFooter',
|
||||||
menu: common.sortMenu(await common.getMenu(db))
|
menu: sortMenu(await getMenu(db))
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
res.status(404).render('error', {
|
res.status(404).render('error', {
|
||||||
|
@ -652,7 +669,7 @@ router.get('/:page?', (req, res, next) => {
|
||||||
message: '404 Error - Page not found',
|
message: '404 Error - Page not found',
|
||||||
helpers: req.handlebars.helpers,
|
helpers: req.handlebars.helpers,
|
||||||
showFooter: 'showFooter',
|
showFooter: 'showFooter',
|
||||||
menu: common.sortMenu(await common.getMenu(db))
|
menu: sortMenu(await getMenu(db))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue