Replacing express with node-static. Releasing 0.0.14
This commit is contained in:
parent
4f0016e150
commit
005ad02f68
|
@ -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",
|
||||
|
|
29
server.js
29
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) {
|
||||
|
|
Loading…
Reference in New Issue