Replacing express with node-static. Releasing 0.0.14

This commit is contained in:
Hexagon 2017-01-17 23:52:55 +01:00
parent 4f0016e150
commit 005ad02f68
2 changed files with 24 additions and 11 deletions

View File

@ -1,6 +1,6 @@
{ {
"name" : "cryptalk", "name" : "cryptalk",
"version" : "1.1.13", "version" : "1.1.14",
"description" : "Encrypted HTML5/Node.JS instant chat", "description" : "Encrypted HTML5/Node.JS instant chat",
"main" : "server.js", "main" : "server.js",
"subdomain": "cryptalk", "subdomain": "cryptalk",
@ -29,8 +29,8 @@
}, },
"bin" : "./server.js", "bin" : "./server.js",
"dependencies": { "dependencies": {
"express": "4.13.3", "node-static": "~0.7.9",
"socket.io": "1.3.7" "socket.io": "~1.7.2"
}, },
"os": [ "os": [
"darwin", "darwin",

View File

@ -1,17 +1,30 @@
#!/usr/bin/env node #!/usr/bin/env node
var express = require('express'), const
app = express(), static = require('node-static'),
server = require('http').createServer(app), port = process.env.PORT || 8080,
io = require('socket.io')(server), path = require('path');
port = process.env.PORT || 8080;
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(){ server.listen(port, function(){
console.log('listening on *:'+port); console.log('listening on *:'+port);
}); });
// Serve /public/* as /
app.use(express.static(__dirname + '/public'));
io.on('connection', function(socket) { io.on('connection', function(socket) {
socket.on('room:join', function(req) { socket.on('room:join', function(req) {