-
Notifications
You must be signed in to change notification settings - Fork 7
/
app.js
57 lines (45 loc) · 1.22 KB
/
app.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
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
var http = require('http');
var express = require('express');
var coinvert = require('coinvert');
var coins;
var wallets = {
doge: 'D6xTowCVvwtNpQe9dKhHH164brvCVapxNr',
btc: '1K3Vs8tPu2YkAoWmrkjUQVJuxr7wgPP3Wf'
};
var targetUsd = 2000;
var app = express();
app.use(express.logger());
app.use(express.compress());
app.use(express.static(__dirname + '/public'));
app.use(express.static(__dirname + '/build'));
app.use(express.static(__dirname + '/public/library'));
app.use(express.directory(__dirname + '/public/library'));
app.get('/campaign', function(req, res){
res.json({
targetUsd: targetUsd,
wallets: wallets,
usd: coins.usd
});
});
// always serve index.html
app.get('*', function(req, res){
res.sendfile('/index.html', { root: __dirname + '/public' });
});
function updateWallets(){
coinvert(targetUsd, wallets, function(err, data){
console.log('got coin data');
console.log(data);
setTimeout(updateWallets, 1000 * 60);
if (err) {
console.error(err.stack);
return;
}
coins = data;
});
}
updateWallets();
var server = http.createServer(app);
server.listen(3333, 'localhost', function(){
console.log('server listening');
});