diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml new file mode 100644 index 0000000..e4a51cd --- /dev/null +++ b/.github/workflows/nodejs.yml @@ -0,0 +1,29 @@ +name: Node CI + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [8.x, 10.x, 12.x] + + steps: + - uses: mrvautin/mongodb-action@v1 + - name: MongoDB + with: + mongo version: '3.4.10' + - uses: actions/checkout@v1 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: npm install, build, and test + run: | + npm install + npm test + env: + CI: true diff --git a/app.js b/app.js index 8d0d573..ddcbdd8 100644 --- a/app.js +++ b/app.js @@ -31,26 +31,31 @@ if(baseConfig === false){ } // Validate the payment gateway config -if(config.paymentGateway === 'paypal'){ - const paypalConfig = ajv.validate(require('./config/paypalSchema'), require('./config/paypal.json')); - 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')); - if(stripeConfig === false){ - console.log(colors.red(`Stripe config is incorrect: ${ajv.errorsText()}`)); - process.exit(2); - } -} -if(config.paymentGateway === '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); - } +switch(config.paymentGateway) +{ + case 'paypal': + const paypalConfig = ajv.validate(require('./config/paypalSchema'), require('./config/paypal.json')); + if(paypalConfig === 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){ + 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){ + console.log(colors.red(`Authorizenet config is incorrect: ${ajv.errorsText()}`)); + process.exit(2); + } + break; } // require the routes diff --git a/package-lock.json b/package-lock.json index 361af05..64699c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3387,10 +3387,13 @@ } }, "eslint-utils": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.3.1.tgz", - "integrity": "sha512-Z7YjnIldX+2XMcjr7ZkgEsOj/bREONV60qYeB/bjMAqqqZ4zxKyWX+BOUkdmRmA9riiIPVvo5x86m5elviOk0Q==", - "dev": true + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.2.tgz", + "integrity": "sha512-eAZS2sEUMlIeCjBeubdj45dmBHQwPHWyBcT1VSYB7o9x9WRRqKxyUoiXlRjyAwzN7YEzHJlYg0NmzDRWx6GP4Q==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.0.0" + } }, "eslint-visitor-keys": { "version": "1.0.0",