-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
47 lines (40 loc) · 1.22 KB
/
index.js
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
41
42
43
44
45
46
47
var ApiBuilder = require('claudia-api-builder'),
api = new ApiBuilder();
const BncClient = require('@binance-chain/javascript-sdk');
const getClient = async (useAwaitSetPrivateKey = true, doNotSetPrivateKey = false) => {
const client = new BncClient("https://testnet-dex.binance.org")
await client.initChain()
const privateKey = '19af207290bdeba210c77eedca2a72d0597bc06986c1b3251cb18db52ce6078f'
if (!doNotSetPrivateKey) {
if (useAwaitSetPrivateKey) {
await client.setPrivateKey(privateKey)
} else {
client.setPrivateKey(privateKey) // test without `await`
}
}
// use default delegates (signing, broadcast)
client.useDefaultSigningDelegate()
client.useDefaultBroadcastDelegate()
return client
}
module.exports = api;
api.get('/', function () {
'use strict';
return 'Hello World';
});
api.get('/people/{name}', function (request) {
'use strict';
return request.pathParams.name + ' is cool!';
});
api.get('/json', function (request) {
'use strict';
return {
name: 'John',
surname: 'Doe',
email: 'johndoe@example.com'
};
});
api.post('/echo', function (request) {
'use strict';
return request.body;
});