diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml new file mode 100644 index 00000000..8fb5b2bf --- /dev/null +++ b/.github/workflows/nodejs.yml @@ -0,0 +1,30 @@ +name: Node Cloud Build + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x] + + steps: + - uses: actions/checkout@v1 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: yarn install and test + run: | + yarn install + yarn test + env: + CI: true diff --git a/examples/database/aws-dynamodb.js b/examples/database/aws-dynamodb.js index 670b3379..fb15d7dc 100644 --- a/examples/database/aws-dynamodb.js +++ b/examples/database/aws-dynamodb.js @@ -1,23 +1,36 @@ const nodeCloud = require("../../lib/"); -const ncAWS = nodeCloud.getProvider("AWS", process.env.ncconf); +const optionsProvider = { + overrideProviders: false +}; +const ncProviders = nodeCloud.getProviders(optionsProvider); +const assert = require("chai").assert; + const options = { apiVersion: "2016-11-15" }; -// get nosql object for AWS -const dynamoDB = ncAWS.nosql(options); +// Initialize dynamoDB object to access AWS DynamoDB +const dynamoDB = ncProviders.aws.nosql(options); const params = { Item: { - artist: { - S: "GG" + id: { + S: "1" + }, + racer: { + S: "Carroll Shelby" } }, ReturnConsumedCapacity: "TOTAL", TableName: "Test" }; -dynamoDB.createItem(params).then((res) => { - assert.equal(res.ConsumedCapacity.TableName, "Test"); - done(); -}); +dynamoDB + .createItem(params) + .then((res) => { + assert.equal(res.ConsumedCapacity.TableName, "Test"); + console.log("Response :", res); + }) + .catch((err) => { + console.log("Error:", err); + }); diff --git a/lib/core/base-provider.js b/lib/core/base-provider.js index 676ddc6e..ddd128fb 100644 --- a/lib/core/base-provider.js +++ b/lib/core/base-provider.js @@ -26,10 +26,20 @@ class Provider { let providersToLoad = {}; - if (options && options.hasOwnProperty("overrideProviders")) { + if ( + options !== null && + options !== undefined && + options.overrideProviders === true + ) { ncConfig.map((provider) => { const module = provider.plugin; - providersToLoad[provider.tag] = module(provider.configPath); + try { + providersToLoad[provider.tag] = module(provider.configPath); + } catch (err) { + throw new Error( + "🤖 It seems you have not added a valid cloud provider" + ); + } }); } else { ncConfig.map((provider) => { @@ -38,7 +48,13 @@ class Provider { } const module = provider.plugin; - providersToLoad[provider.tag] = module(provider.configPath); + try { + providersToLoad[provider.tag] = module(provider.configPath); + } catch (err) { + throw new Error( + "🤖 It seems you have not added a valid cloud provider" + ); + } }); }