code refactored - used switch case instead of if
parent
399343a09d
commit
c42bd43de3
45
app.js
45
app.js
|
@ -31,26 +31,31 @@ if(baseConfig === false){
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the payment gateway config
|
// Validate the payment gateway config
|
||||||
if(config.paymentGateway === 'paypal'){
|
switch(config.paymentGateway)
|
||||||
const paypalConfig = ajv.validate(require('./config/paypalSchema'), require('./config/paypal.json'));
|
{
|
||||||
if(paypalConfig === false){
|
case 'paypal':
|
||||||
console.log(colors.red(`PayPal config is incorrect: ${ajv.errorsText()}`));
|
const paypalConfig = ajv.validate(require('./config/paypalSchema'), require('./config/paypal.json'));
|
||||||
process.exit(2);
|
if(paypalConfig === false){
|
||||||
}
|
console.log(colors.red(`PayPal config is incorrect: ${ajv.errorsText()}`));
|
||||||
}
|
process.exit(2);
|
||||||
if(config.paymentGateway === 'stripe'){
|
}
|
||||||
const stripeConfig = ajv.validate(require('./config/stripeSchema'), require('./config/stripe.json'));
|
break;
|
||||||
if(stripeConfig === false){
|
|
||||||
console.log(colors.red(`Stripe config is incorrect: ${ajv.errorsText()}`));
|
case 'stripe':
|
||||||
process.exit(2);
|
const stripeConfig = ajv.validate(require('./config/stripeSchema'), require('./config/stripe.json'));
|
||||||
}
|
if(stripeConfig === false){
|
||||||
}
|
console.log(colors.red(`Stripe config is incorrect: ${ajv.errorsText()}`));
|
||||||
if(config.paymentGateway === 'authorizenet'){
|
process.exit(2);
|
||||||
const authorizenetConfig = ajv.validate(require('./config/authorizenetSchema'), require('./config/authorizenet.json'));
|
}
|
||||||
if(authorizenetConfig === false){
|
break;
|
||||||
console.log(colors.red(`Authorizenet config is incorrect: ${ajv.errorsText()}`));
|
|
||||||
process.exit(2);
|
case 'authorizenet':
|
||||||
}
|
const authorizenetConfig = ajv.validate(require('./config/authorizenetSchema'), require('./config/authorizenet.json'));
|
||||||
|
if(authorizenetConfig === false){
|
||||||
|
console.log(colors.red(`Authorizenet config is incorrect: ${ajv.errorsText()}`));
|
||||||
|
process.exit(2);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// require the routes
|
// require the routes
|
||||||
|
|
Loading…
Reference in New Issue