diff --git a/package.json b/package.json index 7e715a9..7af1271 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name" : "cryptalk", - "version" : "1.1.13", + "version" : "1.1.14", "description" : "Encrypted HTML5/Node.JS instant chat", "main" : "server.js", "subdomain": "cryptalk", @@ -29,8 +29,8 @@ }, "bin" : "./server.js", "dependencies": { - "express": "4.13.3", - "socket.io": "1.3.7" + "node-static": "~0.7.9", + "socket.io": "~1.7.2" }, "os": [ "darwin", diff --git a/server.js b/server.js index 054efe2..199ba3d 100644 --- a/server.js +++ b/server.js @@ -1,17 +1,30 @@ #!/usr/bin/env node -var express = require('express'), - app = express(), - server = require('http').createServer(app), - io = require('socket.io')(server), - port = process.env.PORT || 8080; +const + static = require('node-static'), + port = process.env.PORT || 8080, + path = require('path'); +var + file, + server, + io; + +// Set up static file location +file = new static.Server(path.resolve(__dirname, 'public')); + +// Create http server, handle static assets +server = require('http').createServer(function (req) { + req.addListener('end', file.serve).resume(); +}); + +// Append socket.io to http server +io = require('socket.io')(server), + +// Listen to port env:PORT or 8080 server.listen(port, function(){ console.log('listening on *:'+port); }); -// Serve /public/* as / -app.use(express.static(__dirname + '/public')); - io.on('connection', function(socket) { socket.on('room:join', function(req) {