title: Nodejs/Expressjs app structure
body: <p>Say i have this code to separate routes in expressjs:    </p>
  
  <pre><code>module.exports = function(express,app,client) {
  
      app.get('/', function(req,res,next) {
          var query = 'SELECT * FROM users LIMIT 10';
          var user = client.query(query, function (err, results, fields) {
              res.render('index', {
                  title: 'test',
                  users: results
              });
              client.end();
          });
      });
  }
  </code></pre>
  
  <p>And require it in <code>app.js</code>:</p>
  
  <pre><code>require('./controllers/routes.js')(express,app,client);
  </code></pre>
  
  <p>1) How do i separate db queries into new files in the best way?</p>
  
  <p>This file would get pretty big even if i separate db logic.</p>
  
  <p>2) What is a good way to separate routes? Maybe separate modules? and then require them all in <code>app.js</code>?</p>