Prerequisites for creating and running the middleware
The reader is expected to be familiar with Node.js/JavaScript programming (especially the Promise pattern) and with the usage of the Node.js and npm tools:
- Install Node.js (https://nodejs.org/en/download/) and npm (https://www.npmjs.com/get-npm).
- Install the fabric-client and fabric-ca-client npm libraries:
- You can install these packages from the npm registry, either manually by running npm install <package-name> or by setting the names and versions in your package.json file. As an example, the package.json in the middleware folder contains the following entries in the dependencies section:
- fabric-ca-client: ^1.1.0
- fabric-client: ^1.1.0
- You can install these packages from the npm registry, either manually by running npm install <package-name> or by setting the names and versions in your package.json file. As an example, the package.json in the middleware folder contains the following entries in the dependencies section:
- This instructs npm to install versions 1.1.0 of both of these packages:
- Alternatively, you can clone the Fabric SDK node (https://github.com/hyperledger/fabric-sdk-node/) source code repository and import the two libraries locally as follows:
- Run npm install in the fabric-client and fabric-ca-client folders
- Install these packages as dependencies, either manually by specifying the path to the preceding folders in middleware/package.json, or by using the npm link command to add symbolic links to the packages in middleware/node_modules
- Alternatively, you can clone the Fabric SDK node (https://github.com/hyperledger/fabric-sdk-node/) source code repository and import the two libraries locally as follows:
In the following sections, we will use the fabric-client library to perform channel and chaincode operations involving the peer and the orderer, and the fabric-ca-client library to perform user registration and enrolment operations involving the CA (or MSP).