app.js:
var express = require('express'),
app = module.exports.app = express();
var server = http.createServer(app);
var socket = require('./libs/sockets')(server);
app.set('socket', socket); // для обращения к сокетам из, например, passport.js
libs/sockets/index.js:
module.exports = function(server) {
var io = require('socket.io')(server);
io.sockets.on('connection', function(socket){
socket.on('connect', function(data){
console.log(data);
});
socket.emit('auth', {hello : 'world222'});
});
return io;
};