Permalink
Browse files

Migrate to Express

  • Loading branch information...
Irvin Ocanto Irvin Ocanto
Irvin Ocanto authored and Irvin Ocanto committed May 12, 2013
1 parent c04d67c commit 8286e2948dc102c2fb816e6cbc98d357b47dac9c
Showing with 25 additions and 7 deletions.
  1. +3 −2 package.json
  2. +22 −5 web.js
View
@@ -1,8 +1,9 @@
{
"name": "spin.it",
- "version": "0.0.1",
+ "version": "0.0.2",
"dependencies": {
- "connect": "2.x"
+ "express": "3.x",
+ "socket.io":"0.9.x"
},
"engines": {
"node": "0.8.x",
View
27 web.js
@@ -1,8 +1,25 @@
-var connect = require('connect'),
- port = process.env.PORT || 8001;
+var 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);

0 comments on commit 8286e29

Please sign in to comment.