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 app = http.createServer(function(req, res, next) {
|
|
|
|
// 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 io = require('socket.io')(app);
|
|
|
|
var data = require('data.io')(io);
|
|
|
|
|
|
|
|
require('./resources')(data);
|
|
|
|
|
|
|
|
app.listen(3000);
|