Task - Generating an Application

How Generate a Starter Application

We're going to assume that you've been through the Getting Started section and would like to now start to look at writing your own application to use Fabric Composer.

To help getting started with this, there's a Yeoman generator that creates a suitable directory structure and helps bring in the required model and network modules.


If you don't already have it, install Yeoman

npm install -g yo

then install the generator for it

npm install -g generator-fabric-composer

Running the generator

yo fabric-composer

What are the questions?

? Your NPM library name: concerto-sample-app
? Short description: Test Concerto project
? Author name: Sophie Black
? Author email: sophie@ampretia.com
? NPM Module name of the Business Network to connect to: digitalproperty-network
? Is the name in NPM registry the same as the Business Network Identifier?: Yes
? What is the Connection Profile to use? defaultProfile
? Enrollment id: WebAppAdmin
? Enrollment Secret: DJY27pEnl16d
configuring: concerto-sample-app
Getting the npm module describing the undefined
   create config/default.json
   create Dockerfile
   create gulpfile.js
   create index.js
   create package.json
   create scripts/docker-compose.yml
   create scripts/setup.sh
   create scripts/teardown.sh
   create .gitignore

What does this do?

Firstly it creates a standard npm module with the usual attributes of name, author, description. Secondly it asks a set of Concerto framework questions to create to help create the sample structure.

  • NPM Module name: What is the name of the business network you want to connect to - and is this the same as the modules NPM registry name
  • Connection Profile: This is the connection profile used to locate ip/ports etc of the running fabric
  • The EnrollmentId/Secret: Are needed to create a connection to the fabric

Testing this has worked

The index.js file is a very simple application that lists the asset registries that have been defined.

Generating Tests

Note that after the application is generated you may choose to add skeletal tests to your application using the composer generator tests command.