-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
58 lines (43 loc) · 1.2 KB
/
app.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
/**
* App
*
* @package node-aquastreamxt
* @author Alexander Dick <alex@dick.at>
*/
aquastreamApi = require('node-aquastreamxt-api');
conf = require('nconf');
fs = require('fs');
var express = require('express'),
http = require('http'),
socketio = require('socket.io'),
routes = require('./routes'),
path = require('path');
// Load config file
conf.file({file: 'config.json'});
app = express();
app.configure(function() {
app.set('port', conf.get('server:port'));
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
});
app.get('/', routes.index);
app.post('/config', function(req, res) {
var key = req.body.key;
var value = req.body.value;
conf.set(key, value);
conf.save();
res.send(conf.get());
});
var server = http.createServer(app).listen(app.get('port'), function(){
console.log("Server listening on port " + app.get('port'));
});
io = socketio.listen(server, {
log: false
});
io.sockets.on('connection', function (socket) {
});