Hyperledger fabric配置node.js

一、配置Swagger-UI

1.你可以使用本地的node.js服务来运行rest-api,确保你本机已经安转node.js,如果没有安装,请安转一个
2.命令行下安转node.js
------npm install http-server -g
3.在你本机上启动http-server运行rest-api
------cd /opt/gopath/src/github.com/hyperledger/fabric/core/rest
-------http-server -a 0.0.0.0 -p 5554 --cors
4.浏览器中输入下面语句,确保能成功连接
------http://localhost:5554/rest_api.json
5.使用命令行下载 Swagger-UI包
------git clone https://github.com/swagger-api/swagger-ui.git
6.到 /swagger-ui/dist 下用浏览器打开index.html
7.启动没有连接到leader or validator的peer节点
----cd /opt/gopath/src/github.com/hyperledger/fabric
-----build/bin/peer node start
8.测试
----cd /opt/gopath/src/github.com/hyperledger/fabric/core/rest
----go test -v -run TestServerOpenchain_API_GetBlockCount


二、Node.Js应用程序
构建并且安装 fabric core.
    cd /opt/gopath/src/github.com/hyperledger/fabric
    make peer
在本地仅仅运行一个节点 (不是一个完整的网络) :
    build/bin/peer node start
配置一个测试区块链数据结构通过vagrant来运行测试接下来重启peer进程.
    cd /opt/gopath/src/github.com/hyperledger/fabric/core/rest
    go test -v -run TestServerOpenchain_API_GetBlockCount
在本地电脑上启动http-server来运行rest_api.json服务.
    npm install http-server -g
    cd /opt/gopath/src/github.com/hyperledger/fabric/core/rest
    http-server -a 0.0.0.0 -p 5554 --cors
下载和解压 Sample_1.zip
    unzip Sample_1.zip -d Sample_1
    cd Sample_1
如果没有默认的URL地址就在openchain.js文件中更新api_url变量以搭配合适的URL
    Update the api_url variable within openchain.js to the appropriate URL if it is not already the default
    var api_url = 'http://localhost:5554/rest_api.json';
运行Node.js app
    node ./openchain.js




  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

The_Web3_社区

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值