-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
71 lines (55 loc) · 3.21 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// index.js
// =============================================================================
// =============================================================================
// =================================BASE SETUP==================================
// =============================================================================
// =============================================================================
// Call the packages we need
var express = require('express'); // call express
var app = express(); // define our app using express
var morgan = require('morgan'); // used to log received requests
var fs = require('fs'); // for file reading/writing
var public_path = __dirname + '/public'; // public path
// To pass original headers through NGINX
app.set('trust proxy', 'loopback');
// use Morgan to log requests to the console
app.use(morgan('short')); // 'dev' for development / 'short' for production
var port = (process.env.ether_port) ? process.env.ether_port : 8081; // set our port
// ==================================Database===================================
var mongodb = require(__dirname + '/database/main.js');
// =================================Controllers=================================
var arbitrageCtrl = require(__dirname + '/controllers/arbitrageCtrl.js');
var ethermineCtrl = require(__dirname + '/controllers/ethermineCtrl.js');
var telegramCtrl = require(__dirname + '/controllers/telegramCtrl.js');
var helpers = require(__dirname + '/utilities/helpers.js');
require(__dirname + '/utilities/cron_jobs.js');
// =============================================================================
// =============================================================================
// ==================================ROUTES=====================================
// =============================================================================
// =============================================================================
// ==================================Middleware=================================
// app.use(function (req, res, next) {
// // Nothing for now
// next();
// });
// ================================Public Folder================================
app.use('/', express.static('public'));
// ===============================General Routes================================
var routes = require(__dirname + '/routes.js')
app.use('/', routes.router);
// =================================Catch 404s==================================
app.use('*',function(req,res){
res.status(404);
res.sendFile(public_path + '/404.html');
});
// =============================================================================
// =============================================================================
// ===============================START THE SERVER==============================
// =============================================================================
// =============================================================================
app.listen(port);
var currentDate = new Date();
currentDate.setTime(Date.now());
dateString = currentDate.toUTCString();
console.log(dateString + ' - Server running at port ' + port);