Nodejs: SocketIO listening to Express app server + very basic config

// set up ------------------------------------------------------------ var express = require('express'), app = express(), engines = require('consolidate'), port = process.env.PORT || 3000; // All links in html or css can be referred to the '/static' "root-path", it will target the './public' folder... app.use('/static', express.static(__dirname + '/public')); // Template engine config ------------------------------------------------------------ app.engine('html', engines.nunjucks); app.set('view engine', 'html'); app.set('views', __dirname + '/views'); // routes ------------------------------------------------------------ require('./app/routes.js')(app); // load our routes // launch ------------------------------------------------------------ var server = require('http').createServer(app) server.listen(port); console.log('App listening on port ' + port); // SocketIO bit ------------------------------------------------------------ var io = require(''); io = io.listen(server); require('./app/sockets.js')(io); // load our sockets and pass in io

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.