-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·43 lines (34 loc) · 1.11 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
'use strict';
//////////////////////////////
// Requires
//////////////////////////////
const express = require('express');
const path = require('path');
const fs = require('fs');
const dotenv = require('dotenv');
const appEnv = require('./lib/env');
const renderer = require('./lib/render');
const stockData = require('./lib/stockdata');
//////////////////////////////
// App Variables
//////////////////////////////
const app = express();
app.engine('html', renderer);
app.set('view engine', 'pug');
app.use(express.static(path.join(__dirname, 'public')));
app.get('/', (req, res) => {
res.render('index');
});
app.get('/detectFourWeekBreakout', stockData.detectFourWeekBreakout);
app.get('/getTickerSymbols', stockData.getTickerSymbols);
//////////////////////////////
// Start the server
//////////////////////////////
app.listen(appEnv.port, () => {
// Mean to console.log out, so disabling
console.log(`Server starting on ${appEnv.url}`); // eslint-disable-line no-console
if (fs.existsSync('.env')) {
console.log('Found local config file'); // eslint-disable-line no-console
dotenv.config();
}
});