From 0a7e207fef02013f93f543b9f1a84d3cbb488c2d Mon Sep 17 00:00:00 2001 From: Michiel Mulders Date: Sat, 20 Jan 2018 22:19:23 +0100 Subject: [PATCH] Finished examples - experimenting with websocket --- examples/basic-usage-boilerplate/README.md | 16 ++++++++++++++++ examples/basic-usage-boilerplate/package.json | 6 +++--- .../src/basic-usage-async-await.js | 5 +++-- .../basic-usage-boilerplate/src/basic-usage.js | 5 +++-- .../basic-usage-boilerplate/src/query-assets.js | 5 +++-- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/examples/basic-usage-boilerplate/README.md b/examples/basic-usage-boilerplate/README.md index 21be56d..5c9f194 100644 --- a/examples/basic-usage-boilerplate/README.md +++ b/examples/basic-usage-boilerplate/README.md @@ -5,6 +5,22 @@ **Basic Usage**: Create asset and transfer it to new owner. -> `npm start` +**Async/Await Basic Usage**: Basic usage example rewritten with async/await. +-> `npm run basic-async` + **Querying for Assets**: Query for assetdata or metadata. -> `npm run query-assets` +**Seed/Keypair Functionality**: Create keypair with bip39 library. +-> `npm run seed-func` + +## Notes +`dotenv` is listed as a dependencies in `package.json`. +If you want to use this, add a `.env` file to the root of this project (same level as this `README.md` file) +and replace the variables to fit your system. + +``` +BIGCHAINDB_API_PATH=http://localhost:9984/api/v1/ +BIGCHAINDB_APP_ID= +BIGCHAINDB_APP_KEY= +``` \ No newline at end of file diff --git a/examples/basic-usage-boilerplate/package.json b/examples/basic-usage-boilerplate/package.json index 7a52d95..5a31f94 100644 --- a/examples/basic-usage-boilerplate/package.json +++ b/examples/basic-usage-boilerplate/package.json @@ -9,8 +9,7 @@ "start": "nodemon src/basic-usage.js --exec babel-node", "query-assets": "nodemon src/query-assets.js --exec babel-node", "seed-func": "nodemon src/seed-func.js --exec babel-node", - "basic-async": "nodemon src/basic-usage-async-await.js --exec babel-node", - "websocket": "nodemon src/websocket.js --exec babel-node" + "basic-async": "nodemon src/basic-usage-async-await.js --exec babel-node" }, "author": "BigchainDB", "license": "MIT", @@ -31,6 +30,7 @@ "private": true, "dependencies": { "bigchaindb-driver": "^3.2.0", - "bip39": "^2.5.0" + "bip39": "^2.5.0", + "dotenv": "^4.0.0" } } diff --git a/examples/basic-usage-boilerplate/src/basic-usage-async-await.js b/examples/basic-usage-boilerplate/src/basic-usage-async-await.js index b07c5d4..b1e18bc 100644 --- a/examples/basic-usage-boilerplate/src/basic-usage-async-await.js +++ b/examples/basic-usage-boilerplate/src/basic-usage-async-await.js @@ -1,10 +1,11 @@ const driver = require('bigchaindb-driver') +require('dotenv').config() // ======== Preparation ======== // const conn = new driver.Connection('https://test.bigchaindb.com/api/v1/', { - app_id: 'c17a9968', - app_key: '0b277b94893e7b0a5b4e6afd6bccb01d' + app_id: process.env.BIGCHAINDB_APP_ID, + app_key: process.env.BIGCHAINDB_APP_KEY }) const alice = new driver.Ed25519Keypair() diff --git a/examples/basic-usage-boilerplate/src/basic-usage.js b/examples/basic-usage-boilerplate/src/basic-usage.js index ea5528e..811c4b6 100644 --- a/examples/basic-usage-boilerplate/src/basic-usage.js +++ b/examples/basic-usage-boilerplate/src/basic-usage.js @@ -1,10 +1,11 @@ const driver = require('bigchaindb-driver') +require('dotenv').config() // ======== Preparation ======== // const conn = new driver.Connection('https://test.bigchaindb.com/api/v1/', { - app_id: 'c17a9968', - app_key: '0b277b94893e7b0a5b4e6afd6bccb01d' + app_id: process.env.BIGCHAINDB_APP_ID, + app_key: process.env.BIGCHAINDB_APP_KEY }) const alice = new driver.Ed25519Keypair() diff --git a/examples/basic-usage-boilerplate/src/query-assets.js b/examples/basic-usage-boilerplate/src/query-assets.js index 2195ad8..b60b5ce 100644 --- a/examples/basic-usage-boilerplate/src/query-assets.js +++ b/examples/basic-usage-boilerplate/src/query-assets.js @@ -1,10 +1,11 @@ const driver = require('bigchaindb-driver') +require('dotenv').config() // ======== Preparation ======== // const conn = new driver.Connection('https://test.bigchaindb.com/api/v1/', { - app_id: 'c17a9968', - app_key: '0b277b94893e7b0a5b4e6afd6bccb01d' + app_id: process.env.BIGCHAINDB_APP_ID, + app_key: process.env.BIGCHAINDB_APP_KEY }) const alice = new driver.Ed25519Keypair()