Skip to content

Commit

Permalink
Migrate to Express
Browse files Browse the repository at this point in the history
  • Loading branch information
Irvin Ocanto authored and Irvin Ocanto committed May 12, 2013
1 parent c04d67c commit 8286e29
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
5 changes: 3 additions & 2 deletions package.json
@@ -1,8 +1,9 @@
{ {
"name": "spin.it", "name": "spin.it",
"version": "0.0.1", "version": "0.0.2",
"dependencies": { "dependencies": {
"connect": "2.x" "express": "3.x",
"socket.io":"0.9.x"
}, },
"engines": { "engines": {
"node": "0.8.x", "node": "0.8.x",
Expand Down
27 changes: 22 additions & 5 deletions web.js
@@ -1,8 +1,25 @@
var connect = require('connect'), var port = process.env.PORT || 8001;
port = process.env.PORT || 8001;

var express = require('express')
, app = express()
, server = require('http').createServer(app)
, io = require('socket.io').listen(server);

server.listen(port);

app.get('/', function (req, res) {
res.sendfile(__dirname + '/index.html');
});

app.use(express.static(__dirname + '/public'));

io.sockets.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data) {
console.log(data);
});
});


connect.createServer(
connect.static(__dirname + '/public')
).listen( port );


console.log("Listening on " + port); console.log("Listening on " + port);

0 comments on commit 8286e29

Please sign in to comment.