For my REST api I have create a file for each route.
app.get('/api/user', routes.user.index);
app.get('/api/user/login', routes.user.login);
etc, etc.
Now I'm introducing socket.io to the backend and it seems I can only call one function for all socket events.
var socket = require('./socket/stuff.js');
io.sockets.on('connection', function(sock){
socket.stuff(sock, io);
});
How should I break up the ./socket/stuff.js file (which exports stuff). 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.
I imagine I would have:
./socket/chat.js
./socket/user.js
etc. etc.