forked from RickReesen/hyperledger-hackathon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
40 lines (32 loc) · 912 Bytes
/
app.js
File metadata and controls
40 lines (32 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var express = require('express');
var blockchain = require('./blockchain/blockchain');
var app = express();
// initialize blockchain
blockchain.init();
app.get('/', function (req, res) {
res.send('Hello Hackathon!');
});
app.get('/query', function (req, res) {
blockchain.query('query','emma1',['a'],function(e,o){
if (!o) {
console.log('user not found');
} else {
console.log('success= '+ o);
var result = 'balance= '+o;
res.send(result);
}
});
});
app.get('/invoke', function (req, res) {
var result = blockchain.invoke('invoke','emma1',['a','b','100'],function(e,o){
if (!o) {
console.log('user not found');
} else {
console.log('success= ' + o);
res.send(o);
}
});
});
app.listen(3000, function () {
console.log('Boilerplate app listening on port 3000');
});