How to use composer-client - 10 common examples

To help you get started, we’ve selected a few composer-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rddill-IBM / ZeroToBlockchain / Chapter08 / controller / restapi / features / composer / hlcClient.js View on Github external
exports.getMyOrders = function (req, res, next) {
    // connect to the network
    let method = 'getMyOrders';
    console.log(method+' req.body.userID is: '+req.body.userID );
    let allOrders = new Array();
    let businessNetworkConnection;
    if (svc.m_connection === null) {svc.createMessageSocket();}
    let ser;
    let archiveFile = fs.readFileSync(path.join(path.dirname(require.main.filename),'network','dist','zerotoblockchain-network.bna'));
    businessNetworkConnection = new BusinessNetworkConnection();
    return BusinessNetworkDefinition.fromArchive(archiveFile)
    .then((bnd) => {
        ser = bnd.getSerializer();
        //
        // v0.14
        // return businessNetworkConnection.connect(config.composer.connectionProfile, config.composer.network, req.body.userID, req.body.secret)
        //
        // v0.15
        console.log(method+' req.body.userID is: '+req.body.userID );
        return businessNetworkConnection.connect(req.body.userID)
        .then(() => {
            return businessNetworkConnection.query('selectOrders')
            .then((orders) => {
                allOrders = new Array();
                for (let each in orders)
                    { (function (_idx, _arr)
github rddill-IBM / ZeroToBlockchain / Chapter08 / Documentation / answers / composer / hlcClient_complete.js View on Github external
exports.getMyOrders = function (req, res, next) {
    // connect to the network
    let method = 'getMyOrders';
    console.log(method+' req.body.userID is: '+req.body.userID );
    let allOrders = new Array();
    let businessNetworkConnection;
    if (svc.m_connection === null) {svc.createMessageSocket();}
    let ser;
    let archiveFile = fs.readFileSync(path.join(path.dirname(require.main.filename),'network','dist','zerotoblockchain-network.bna'));
    businessNetworkConnection = new BusinessNetworkConnection();
    return BusinessNetworkDefinition.fromArchive(archiveFile)
    .then((bnd) => {
        ser = bnd.getSerializer();
        //
        // v0.14
        // return businessNetworkConnection.connect(config.composer.connectionProfile, config.composer.network, req.body.userID, req.body.secret)
        //
        // v0.15
        console.log(method+' req.body.userID is: '+req.body.userID );
        return businessNetworkConnection.connect(req.body.userID)
        .then(() => {
            return businessNetworkConnection.query('selectOrders')
            .then((orders) => {
                allOrders = new Array();
                for (let each in orders)
                    { (function (_idx, _arr)
github rddill-IBM / ZeroToBlockchain / Chapter09 / controller / restapi / features / composer / hlcClient.js View on Github external
exports.getMyOrders = function (req, res, next) {
    // connect to the network
    let method = 'getMyOrders';
    console.log(method+' req.body.userID is: '+req.body.userID );
    let allOrders = new Array();
    let businessNetworkConnection;
    if (svc.m_connection === null) {svc.createMessageSocket();}
    let ser;
    let archiveFile = fs.readFileSync(path.join(path.dirname(require.main.filename),'network','dist','zerotoblockchain-network.bna'));
    businessNetworkConnection = new BusinessNetworkConnection();
    return BusinessNetworkDefinition.fromArchive(archiveFile)
    .then((bnd) => {
        ser = bnd.getSerializer();
        //
        // v0.14
        // return businessNetworkConnection.connect(config.composer.connectionProfile, config.composer.network, req.body.userID, req.body.secret)
        //
        // v0.15
        console.log(method+' req.body.userID is: '+req.body.userID );
        return businessNetworkConnection.connect(req.body.userID)
        .then(() => {
            return businessNetworkConnection.query('selectOrders')
            .then((orders) => {
                allOrders = new Array();
                for (let each in orders)
                    { (function (_idx, _arr)
github rddill-IBM / ZeroToBlockchain / Chapter09 / Documentation / answers / composer / hlcClient_complete.js View on Github external
exports.getMyOrders = function (req, res, next) {
    // connect to the network
    let method = 'getMyOrders';
    console.log(method+' req.body.userID is: '+req.body.userID );
    let allOrders = new Array();
    let businessNetworkConnection;
    if (svc.m_connection === null) {svc.createMessageSocket();}
    let ser;
    let archiveFile = fs.readFileSync(path.join(path.dirname(require.main.filename),'network','dist','zerotoblockchain-network.bna'));
    businessNetworkConnection = new BusinessNetworkConnection();
    return BusinessNetworkDefinition.fromArchive(archiveFile)
    .then((bnd) => {
        ser = bnd.getSerializer();
        //
        // v0.14
        // return businessNetworkConnection.connect(config.composer.connectionProfile, config.composer.network, req.body.userID, req.body.secret)
        //
        // v0.15
        console.log(method+' req.body.userID is: '+req.body.userID );
        return businessNetworkConnection.connect(req.body.userID)
        .then(() => {
            return businessNetworkConnection.query('selectOrders')
            .then((orders) => {
                allOrders = new Array();
                for (let each in orders)
                    { (function (_idx, _arr)
github accordproject / concerto / packages / generator-fabric-composer / generators / angular / templates / app.js View on Github external
app.use(function(req, res, next) {
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,PATCH,OPTIONS');
  res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With');
  next();
});

// mount the client directory at root
app.use(express.static(path.join(__dirname, 'src')));

// mount the root node_modules at node_modules
app.use('/node_modules', express.static(__dirname + '/node_modules'));


const BusinessNetworkConnection = require('composer-client').BusinessNetworkConnection;
let businessNetworkConnection = new BusinessNetworkConnection();

try{
  return createcomposerRouter(connectionProfileName, networkIdentifier, enrollmentId, enrollmentSecret)
  .then((router) => {
          // attach the Router to Express
          app.use('/api/v1/', router );
  })
  .then(() => {
    // register a route for static resources
    app.get('/*', (req, res, next) => {
      res.sendFile(__dirname + '/src/index.html');
    });

    // start Express listening on a port
    const server = app.listen(7070, () => {
        console.log('App listening on port 7070');
github rddill-IBM / ZeroToBlockchain / Chapter10 / controller / restapi / features / composer / hlcClient.js View on Github external
exports.getMyOrders = function (req, res, next) {
    // connect to the network
    let packageJSON = JSON.parse(fs.readFileSync(path.join(path.dirname(require.main.filename),'network','package.json')));
    let allOrders = new Array();
    let businessNetworkConnection;
    let factory;
    if (svc.m_connection == null) {svc.createMessageSocket();}
    let ser;
    let archiveFile = fs.readFileSync(path.join(path.dirname(require.main.filename),'network','dist','zerotoblockchain-network.bna'));
    businessNetworkConnection = new BusinessNetworkConnection();
    return BusinessNetworkDefinition.fromArchive(archiveFile)
    .then((bnd) => {
        ser = bnd.getSerializer();
        return businessNetworkConnection.connect(config.composer.connectionProfile, config.composer.network, req.body.userID, req.body.secret)
            .then(() => {    
                return businessNetworkConnection.query('selectOrders')
                .then((orders) => {
                        let jsn;
                        let allOrders = new Array();
                        for (let each in orders)
                            { (function (_idx, _arr)
                                {
                                    let _jsn = ser.toJSON(_arr[_idx]);
                                    _jsn.id = _arr[_idx].orderNumber;
                                    allOrders.push(_jsn);                                
                                })(each, orders)
github IBM / BlockchainSmartContractTrading-CompositeJourney / test / productAuction.js View on Github external
async function useIdentity(cardName) {
    await businessNetworkConnection.disconnect();
    businessNetworkConnection = new BusinessNetworkConnection({
      cardStore: cardStore
    });
    events = [];
    businessNetworkConnection.on('event', (event) => {
      events.push(event);
    });
    await businessNetworkConnection.connect(cardName);
    factory = businessNetworkConnection.getBusinessNetwork().getFactory();
  }
  it('Authorized owner should start the bidding', async () => {
github micklynch / patient-data-network / test / logic.js View on Github external
async function useIdentity(cardName) {
        await businessNetworkConnection.disconnect();
        businessNetworkConnection = new BusinessNetworkConnection({ cardStore: cardStore });
        events = [];
        businessNetworkConnection.on('event', (event) => {
            events.push(event);
        });
        await businessNetworkConnection.connect(cardName);
        factory = businessNetworkConnection.getBusinessNetwork().getFactory();
    }
github accordproject / concerto / packages / composer-tests-functional / systest / transactions.native.js View on Github external
let deployOtherNetwork = async (cardName, networkName, otherChannel) => {
            otherCardStore = await deployOther(cardName, networkName, otherChannel);
            otherClient = new BusinessNetworkConnection({cardStore : otherCardStore});
            await otherClient.connect(cardName);
        };
github aprilsnows / hyperledger-composer-supply-chain-network / test / sample.js View on Github external
.then(() => {
                businessNetworkConnection = new BusinessNetworkConnection({ fs: bfs_fs });
                return businessNetworkConnection.connect('defaultProfile', 'hyperledger-composer-supply-chain-network', 'admin', 'adminpw');
            });
    });

composer-client

The node.js client library for Hyperledger Composer, a development framework for Hyperledger Fabric

Apache-2.0
Latest version published 5 years ago

Package Health Score

45 / 100
Full package analysis

Popular composer-client functions