title: RESTful backend and socket.io to sync
body: <p>Today, i had the idea of the following setup. Create a <code>nodejs</code> server along with <code>express</code> and <code>socket.io</code>. With express, i would create a RESTful API, which is connected to a mongo. BackboneJS or similar would connect the client to that REST API.<br>
  Now every time the mongodb(ie the data in it iam interested in) changes, socket.io would fire an event to the client, which would carry a courser to the data which has changed. The client then would trigger the appropriate AJAX requests to the REST to get the new data, where it needs it. </p>
  
  <p>So, the socket.io connection would behave like a synchronize trigger. It would be there for the entire visit and could also manage sessions that way. All the payload would be send over http. </p>
  
  <p>Pros:</p>
  
  <ul>
  <li>REST API for use with other clients than web</li>
  <li>Auth could be done entirely over socket.io. Only sending token along with REST requests.</li>
  <li>Use the benefits of REST.</li>
  <li>Would also play nicely with pub/sub service like Redis'</li>
  </ul>
  
  <p>Cons:</p>
  
  <ul>
  <li>Greater overhead, than using pure socket.io.</li>
  </ul>
  
  <p>What do you think, are there any great disadvantages i did not think of?   </p>