-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (23 loc) · 788 Bytes
/
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
var express = require('express');
var path = require('path');
var app = express();
var api = require('./api.js');
if (process.env.stage === 'development')
require('dotenv').load();
app.set('port', (process.env.PORT || 5000));
app.use(express.static(__dirname + '/dist2'));
app.get('/api', async function(request, response) {
const results = await api.retrieveResults();
response.send(results);
});
app.get('/api/daily', async function(request, response) {
const results = await api.retrieveDailyStats((results) => {
response.send(results);
});
});
app.get('*', function(request, response) {
response.sendFile(path.join(__dirname, '/dist2/index.html'));
});
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});