GithubHelp home page GithubHelp logo

firstzzq / hyperledger-simple-app Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zhazhalaila/hyperledger-simple-app

0.0 0.0 0.0 4.54 MB

A simplest app base on Hyperledger Fabric

Shell 6.91% Go 16.33% JavaScript 61.06% CSS 15.69%

hyperledger-simple-app's Introduction

hyperledger-simple-app

Build Status

基于Hyperledger Fabric的一个极简App

English Docment

chaincode 由@DevilExileSu所编写

在此之前请确保已安装Hyperledger Fabric(本项目基于Hyperledger Fabric v1.1)

库版本:

npm 5.6.0 (建议大于或等于此版本)
node.js v8.11.3 (建议大于或等于此版本)
angularjs 1.4.3

如有Bug,欢迎提出

安装及配置

Step 1:

git clone https://github.com/zhazhalaila/hyperledger-simple-app.git

进入source-app目录下

Step 2:

npm install
//安装时速度可能会很慢,静等即可

Step 3:

./startFabric.sh
若遇到权限问题执行chmod a+x startFabric.sh
若仍有问题进入basic-network文件夹下执行 chmod a+x start.sh

Step 4:

node registerAdmin.js
node registerUser.js
node server.js

访问http://localhost:8000

由于没有初始化信息,因此需要先提交表单信息才可以查询出信息

在填写表单信息时,没有做过多的处理,因此每个选项都要尽量填写(配料的表单可以不填写完)

配料及食品信息对于同一个Id只能添加一次,中转信息可以添加多次

url & json 格式

获取食品信息

http://localhost:8000/source/:id

{"FoodName":"Apple","FoodSpec":"123456","FoodMFGDate":"2018-8-24","FoodEXPDate":"10day","FoodLOT":"123","FoodQSID":"456","FoodMFRSName":"lalala","FoodProPrice":"2","FoodProPlace":"zhengzhou"}

获取食品配料信息

http://localhost:8000/part/:id

[{"IngID":"1","IngName":"a"},{"IngID":"2","IngName":"b"},{"IngID":"3","IngName":"c"},{"IngID":"4","IngName":"d"},{"IngID":"5","IngName":"e"}]

获取交易(运输)信息

http://localhost:8000/transit/:id

[{"LogDepartureTm":"14:20","LogArrivalTm":"16:40","LogMission":"Store","LogDeparturePl":"zhengzhou","LogDest":"wuhan","LogToSeller":"lalala","LogStorageTm":"1day","LogMOT":"truck","LogCopName":"shunfeng","LogCost":"10"},{"LogDepartureTm":"16:50","LogArrivalTm":"18:50","LogMission":"Store","LogDeparturePl":"wuhan","LogDest":"guangzhou","LogToSeller":"lalala","LogStorageTm":"1day","LogMOT":"truck","LogCopName":"shunfeng","LogCost":"10"}]

部署在服务器上

仅需修改server.js文件最后几行代码

var port = process.env.PORT || 3389; //端口修改为服务器的安全组端口

app.listen(port, '0.0.0.0', function(){
 console.log("Live on port: " + port);
});

重要的文件说明(basic-network文件夹不必要搞懂,因为我自己也不懂,但是这并不影响写项目):

source-app
    server.js  启动
    routes.js  定义路由
    controller.js  路由
chaincode
    source-app
        source-app.go chaincode

一般来说,路由会在routes.js文件中定义,但是这样不方便路由复用,因此分为两个脚本

参考链接

Education

Writing Your First Application

注释说明:

除了chaincode,其余大部分.js文件都是参照以上参考链接所写,因此注释为英文

hyperledger-simple-app's People

Contributors

zhazhalaila avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.