-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
73 lines (73 loc) · 2.31 KB
/
server.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Generated by LiveScript 1.5.0
(function(){
var express, app, main, startCampaignDate, toDate, buildRates;
express = require('express');
app = express();
main = require('./rate.js');
startCampaignDate = 1496063101;
toDate = new Date();
main.$on('create-index-start', function(arg$){
var startCampaignDate;
startCampaignDate = arg$.startCampaignDate;
return console.log('create-index-start', startCampaignDate);
}).$on('load-rates', function(arg$){
var startCampaignDate, toDate, currentUrl;
startCampaignDate = arg$.startCampaignDate, toDate = arg$.toDate, currentUrl = arg$.currentUrl;
return console.log('load-rates', startCampaignDate, currentUrl);
}).$on('aggregation-start', function(arg$){
var start, length;
start = arg$.start, length = arg$.length;
return console.log('aggregation-start', start, length);
}).$on('aggregation-stop', function(arg$){
var end, duration;
end = arg$.end, duration = arg$.duration;
return console.log('aggregation-stop', end, duration);
}).$on('create-index-end', function(arg$){
var startCampaignDate;
startCampaignDate = arg$.startCampaignDate;
return console.log('create-index-end', startCampaignDate);
});
app.get('/', function(req, res){
return res.send("try to use /rate/:date or /status");
});
app.get('/rate/:date', function(req, res){
return res.send(main.getRate(req.params.date));
});
app.get('/status', function(req, res){
var ref$;
return res.send((ref$ = main.rateIndex.running) != null
? ref$
: {
serverStarting: true
});
});
app.get('/all-rates', function(req, res){
return res.send(res.send(main.rateIndex));
});
buildRates = function(cb){
return main.createRateIndex({
startCampaignDate: startCampaignDate,
currencyPair: 'BTC_ETH',
toDate: toDate
}, function(err, btc_eth){
if (err != null) {
return err;
}
main.createRateIndex({
startCampaignDate: startCampaignDate,
currencyPair: 'USDT_ETH',
toDate: toDate
}, function(err, usdt_eth){
if (err != null) {
return err;
}
cb(null, {
btc_eth: btc_eth,
usdt_eth: usdt_eth
});
});
});
};
app.listen(8080);
buildRates(function(err, rates){});
}).call(this);