title: how to organize socket handling in node.js and socket.io app
body: <p>For my REST api I have create a file for each route.</p>
  
  <pre><code>app.get('/api/user', routes.user.index);
  app.get('/api/user/login', routes.user.login);
  </code></pre>
  
  <p>etc, etc.</p>
  
  <p>Now I'm introducing socket.io to the backend and it seems I can only call one function for all socket events.</p>
  
  <pre><code>var socket = require('./socket/stuff.js');
  
  io.sockets.on('connection', function(sock){
      socket.stuff(sock, io);
  });
  </code></pre>
  
  <p>How should I break up the <code>./socket/stuff.js</code> file (which exports <code>stuff</code>). Into separate files. I would like to eventually replace my REST api with sockets, but I don't want everything to be in one file.</p>
  
  <p>I imagine I would have:</p>
  
  <pre><code>./socket/chat.js
  ./socket/user.js
  </code></pre>
  
  <p>etc. etc.</p>