Skip to content

Latest commit

 

History

History
 
 

backend

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Part 3 - Set Up and run a Client Application

The client application is based on Node.js. We use an expressjs REST API to interact with the ledger and provide a public react frontend.

Install Node.js requirements

First install the required node_modules.

# make sure you are in the backend folder
pwd
# > /root/fabric/fabricStarterKit/backend

# have a look into the package.json file if you are interested
npm install

Add a User to the Wallet

The client application needs a user to interact with the ledger. We can use [email protected] which was created during the boot process.

The second step is to add this user to the clients local filesystem wallet. We can do that with the following command.

node cli/addToWallet.js
# > done

# check the wallet
tree wallet

# you should see the following output
wallet
└── [email protected]

# feel free to inspect that file
cat wallet/[email protected] | jq .

Install global helper if needed

We can install some global and common helper tools.

npm install nodemon mocha -g

Start REST API

We need another tmux panel.

Create a new panel horizontally
CTRL + b " (double-quots)

Start expressjs.

nodemon start index.js

Test with cli commands

We need another tmux panel.

Create a new panel horizontally
CTRL + b " (double-quots)

# call a specific test with mocha
# possible values ['api','setData','getData','delAsset','getAllAssets','getHistory']

mocha -g "getAllAssets" cli/commands.js

Index | Previous | Next