Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Express 4 and Passing to routes.
var app = express(); = require('')();
var routes = require('./routes/index')(;
app.use('/', routes);
//Normal code here
//then at the bottom:
module.exports = function (io) {
io.on('connection', function (socket) {
console.log('User has connected to Index');
//ON Events
socket.on('admin', function () {
console.log('Successful Socket Test');
//End ON Events
return router;
* Create HTTP server
var server = http.createServer(app);;
* Listen on provided port, on all network interfaces.
server.on('error', onError);
server.on('listening', onListening);
* Normalize a port into a number, string, or false.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment