nci/app.js

33 lines
722 B
JavaScript
Raw Normal View History

2015-04-10 19:23:52 +00:00
'use strict';
var http = require('http');
var nodeStatic = require('node-static');
2015-04-10 20:17:03 +00:00
var jade = require('jade');
2015-04-10 19:23:52 +00:00
var staticServer = new nodeStatic.Server('./static');
var server = http.createServer(function(req, res, next) {
2015-04-10 19:23:52 +00:00
// serve index for all app pages
2015-04-10 20:17:03 +00:00
if (req.url.indexOf('/data.io.js') === -1) {
if (req.url.indexOf('/js') === -1) {
// Compile a function
var index = jade.compileFile(__dirname + '/views/index.jade');
res.write(index());
res.end();
} else {
2015-04-10 19:23:52 +00:00
staticServer.serve(req, res);
}
}
});
var socketio = require('socket.io')(server);
var dataio = require('./dataio')(socketio);
2015-04-10 19:23:52 +00:00
var app = {
server: server,
dataio: dataio
};
2015-04-10 19:23:52 +00:00
require('./resources')(app);
app.server.listen(3000);