How to use socket.io in express routes? Proper way to return JSON using node or Express 4.x API - express() /** * socket.id count 4 roomid * nodejs. 5.1.0 * express 4.13.3 * socket.io 1.3.7 */ app.get( '/api/v1/status/join/:roomid', function(req, res){ var roomJoined = 0; try{ roomJoined = _.pairs(io.sockets.adapter.rooms[req.params.roomid]).length; }catch(e){ console.error('/api/v1/status/join/..