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",
"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",

View File

@ -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) {