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