Linting
parent
9f1eca7b02
commit
e5ef7af4cc
|
@ -0,0 +1,2 @@
|
|||
**/*.min.js
|
||||
pm2.config.js
|
11
app.js
11
app.js
|
@ -23,7 +23,7 @@ const Ajv = require('ajv');
|
|||
const ajv = new Ajv({ useDefaults: true });
|
||||
|
||||
// get config
|
||||
let config = common.getConfig();
|
||||
const config = common.getConfig();
|
||||
|
||||
const baseConfig = ajv.validate(require('./config/baseSchema'), config);
|
||||
if(baseConfig === false){
|
||||
|
@ -34,24 +34,21 @@ if(baseConfig === false){
|
|||
// Validate the payment gateway config
|
||||
switch(config.paymentGateway){
|
||||
case'paypal':
|
||||
const paypalConfig = ajv.validate(require('./config/paypalSchema'), require('./config/paypal.json'));
|
||||
if(paypalConfig === false){
|
||||
if(ajv.validate(require('./config/paypalSchema'), require('./config/paypal.json')) === false){
|
||||
console.log(colors.red(`PayPal config is incorrect: ${ajv.errorsText()}`));
|
||||
process.exit(2);
|
||||
}
|
||||
break;
|
||||
|
||||
case'stripe':
|
||||
const stripeConfig = ajv.validate(require('./config/stripeSchema'), require('./config/stripe.json'));
|
||||
if(stripeConfig === false){
|
||||
if(ajv.validate(require('./config/stripeSchema'), require('./config/stripe.json')) === false){
|
||||
console.log(colors.red(`Stripe config is incorrect: ${ajv.errorsText()}`));
|
||||
process.exit(2);
|
||||
}
|
||||
break;
|
||||
|
||||
case'authorizenet':
|
||||
const authorizenetConfig = ajv.validate(require('./config/authorizenetSchema'), require('./config/authorizenet.json'));
|
||||
if(authorizenetConfig === false){
|
||||
if(ajv.validate(require('./config/authorizenetSchema'), require('./config/authorizenet.json')) === false){
|
||||
console.log(colors.red(`Authorizenet config is incorrect: ${ajv.errorsText()}`));
|
||||
process.exit(2);
|
||||
}
|
||||
|
|
|
@ -23,5 +23,6 @@
|
|||
"paymentGateway": "stripe",
|
||||
"databaseConnectionString": "mongodb://127.0.0.1:27017/expresscart",
|
||||
"theme": "Cloth",
|
||||
"trackStock": false
|
||||
"trackStock": false,
|
||||
"orderHook": ""
|
||||
}
|
||||
|
|
|
@ -242,53 +242,53 @@ const updateConfig = (fields) => {
|
|||
_.forEach(fields, (value, key) => {
|
||||
settingsFile[key] = value;
|
||||
if(key === 'customCss_input'){
|
||||
settingsFile['customCss'] = escape.encode(uglifycss.processString(value));
|
||||
settingsFile.customCss = escape.encode(uglifycss.processString(value));
|
||||
}
|
||||
if(key === 'footerHtml_input'){
|
||||
const footerHtml = typeof value !== 'undefined' || value === '' ? escape.encode(value) : '';
|
||||
settingsFile['footerHtml'] = footerHtml;
|
||||
settingsFile.footerHtml = footerHtml;
|
||||
}
|
||||
if(key === 'googleAnalytics_input'){
|
||||
const googleAnalytics = typeof value !== 'undefined' ? escape.encode(value) : '';
|
||||
settingsFile['googleAnalytics'] = googleAnalytics;
|
||||
settingsFile.googleAnalytics = googleAnalytics;
|
||||
}
|
||||
});
|
||||
|
||||
// delete settings
|
||||
delete settingsFile['customCss_input'];
|
||||
delete settingsFile['footerHtml_input'];
|
||||
delete settingsFile['googleAnalytics_input'];
|
||||
delete settingsFile.customCss_input;
|
||||
delete settingsFile.footerHtml_input;
|
||||
delete settingsFile.googleAnalytics_input;
|
||||
|
||||
if(fields['emailSecure'] === 'on'){
|
||||
settingsFile['emailSecure'] = true;
|
||||
if(fields.emailSecure === 'on'){
|
||||
settingsFile.emailSecure = true;
|
||||
}else{
|
||||
settingsFile['emailSecure'] = false;
|
||||
settingsFile.emailSecure = false;
|
||||
}
|
||||
|
||||
if(!fields['menuEnabled']){
|
||||
settingsFile['menuEnabled'] = false;
|
||||
if(!fields.menuEnabled){
|
||||
settingsFile.menuEnabled = false;
|
||||
}else{
|
||||
settingsFile['menuEnabled'] = true;
|
||||
settingsFile.menuEnabled = true;
|
||||
}
|
||||
|
||||
if(fields['emailPort']){
|
||||
settingsFile['emailPort'] = parseInt(fields['emailPort']);
|
||||
if(fields.emailPort){
|
||||
settingsFile.emailPort = parseInt(fields.emailPort);
|
||||
}
|
||||
|
||||
if(fields['flatShipping']){
|
||||
settingsFile['flatShipping'] = parseInt(fields['flatShipping']);
|
||||
if(fields.flatShipping){
|
||||
settingsFile.flatShipping = parseInt(fields.flatShipping);
|
||||
}
|
||||
|
||||
if(fields['freeShippingAmount']){
|
||||
settingsFile['freeShippingAmount'] = parseInt(fields['freeShippingAmount']);
|
||||
if(fields.freeShippingAmount){
|
||||
settingsFile.freeShippingAmount = parseInt(fields.freeShippingAmount);
|
||||
}
|
||||
|
||||
if(fields['productsPerRow']){
|
||||
settingsFile['productsPerRow'] = parseInt(fields['productsPerRow']);
|
||||
if(fields.productsPerRow){
|
||||
settingsFile.productsPerRow = parseInt(fields.productsPerRow);
|
||||
}
|
||||
|
||||
if(fields['productsPerPage']){
|
||||
settingsFile['productsPerPage'] = parseInt(fields['productsPerPage']);
|
||||
if(fields.productsPerPage){
|
||||
settingsFile.productsPerPage = parseInt(fields.productsPerPage);
|
||||
}
|
||||
|
||||
// If we have a local settings file (not git tracked) we loop its settings and save
|
||||
|
@ -509,7 +509,7 @@ const getData = (req, page, query) => {
|
|||
query = {};
|
||||
}
|
||||
|
||||
query['productPublished'] = { $ne: false };
|
||||
query.productPublished = { $ne: false };
|
||||
|
||||
// Run our queries
|
||||
return Promise.all([
|
||||
|
|
|
@ -13,7 +13,7 @@ router.get('/checkout_return', (req, res, next) => {
|
|||
const db = req.app.db;
|
||||
const config = req.app.config;
|
||||
const paymentId = req.session.paymentId;
|
||||
const payerId = req.query['PayerID'];
|
||||
const payerId = req.query.PayerID;
|
||||
|
||||
const details = { payer_id: payerId };
|
||||
paypal.payment.execute(paymentId, details, (error, payment) => {
|
||||
|
|
|
@ -356,12 +356,12 @@ router.post('/admin/product/update', restrict, checkAccess, async (req, res) =>
|
|||
// if no featured image
|
||||
if(!product.productImage){
|
||||
if(images.length > 0){
|
||||
productDoc['productImage'] = images[0].path;
|
||||
productDoc.productImage = images[0].path;
|
||||
}else{
|
||||
productDoc['productImage'] = '/uploads/placeholder.png';
|
||||
productDoc.productImage = '/uploads/placeholder.png';
|
||||
}
|
||||
}else{
|
||||
productDoc['productImage'] = product.productImage;
|
||||
productDoc.productImage = product.productImage;
|
||||
}
|
||||
|
||||
try{
|
||||
|
|
Loading…
Reference in New Issue