Move socket code to route index.js.