-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
39 lines (32 loc) · 910 Bytes
/
server.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
var express = require('express'),
harp = require('harp'),
path = require('path'),
fs = require('fs'),
exec = require('child_process').exec,
events = require('./events'),
router = require('./router'),
app = express();
// Static Server
app.use(express.static(__dirname + '/public'));
// Static Routes without Extension
app.use(router);
// Fetch Events
app.get('/events.json', function (req, res) {
events(function (err, data) {
if (err) {
return res.status(500).send(err.message);
}
res.send(data);
});
});
// Update site
// TODO: Deprecate in favor of a real solution
app.post('/update', function (req, res) {
exec('git pull && grunt build', function (err, stdout, stderr) {
if (err) return;
console.log(stdout);
throw new Error('Restart action required');
});
});
app.listen(8080);
console.log("ColombiaJS started");