-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
47 lines (37 loc) · 1.29 KB
/
server.js
File metadata and controls
47 lines (37 loc) · 1.29 KB
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
require("./boot");
let rp = require('request-promise');
let express = require('express'),
app = express(),
port = process.env.PORT || 3000;
let bodyParser = require('body-parser');
let MongoClient = require('mongodb').MongoClient;
let url = "mongodb://localhost:27017/";
MongoClient.connect(url, function (err, client) {
global.MongoClient = client;
console.log("Connected correctly to server");
const db = client.db("tikncc");
global.DB = db;
boot();
});
function pollCrons() {
rp.get(CONFIG.REFRESH_ENDPOINTS, {})
.then(data => {
// console.log("DONE");
}).catch(console.log);
}
setInterval(pollCrons, 1000 * 15);
function boot() {
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.listen(port);
console.log('API Server started on: ' + port);
let routes = require("./modules/currencies/routes");
//register api
app.use("/api/", routes);
const wsAPI = require("./modules/currencies/services/WebsocketAPI");
const Currencies = require("./modules/currencies/services/Currencies");
const Rates = require("./modules/currencies/services/RateSync");
Currencies.init(CONFIG.AVAILABLE_CURRENCIES);
Rates.init(CONFIG.AVAILABLE_CURRENCIES);
app.use(express.static('www'))
}