-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.js
More file actions
58 lines (44 loc) · 1.4 KB
/
app.js
File metadata and controls
58 lines (44 loc) · 1.4 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
48
49
50
51
52
53
54
55
56
57
58
// Server and express variables
var express = require('express');
var app = express();
// Big objects
health = {};
location = {};
social = {};
this.secrets = require(__dirname + '/secrets/secrets.json');
var secrets = this.secrets;
var healthWorker = require(__dirname + '/workers/healthWorker');
var locationWorker = require(__dirname + '/workers/locationWorker');
var socialWorker = require(__dirname + '/workers/socialWorker');
// Workers gathering information
// Update health data and move into health object
healthWorker.healthUpdates(function (healthData) {
health = healthData;
});
// Update location data and move into location object
locationWorker.locationUpdates(function (locationData) {
location = locationData;
})
// Update social data and move into social object
socialWorker.socialUpdates(function (socialData) {
social = socialData;
});
// IDK
app.use(express.static(__dirname + '/public'));
app.get('/', function(req, res) {
// Send the index file
res.sendfile('index.html');
});
app.get('/health', function(req, res) {
res.json(health);
});
app.get('/location', function(req, res) {
res.json(location);
});
app.get('/social', function(req, res) {
res.json(social);
});
// Set up express server on port 3000
var server = app.listen(3000, function () {
console.log('Listening on port %d', server.address().port);
});