title: Connect and Express utils
body: <p>I'm new in the world of Node.js</p>
  
  <p>According to this topic: <a href="https://stackoverflow.com/q/5284340/492638">What is Node.js' Connect, Express and “middleware”?</a><br>
  I learned that <a href="http://www.senchalabs.org/connect/" rel="nofollow noreferrer">Connect</a> was part of <a href="http://expressjs.com/guide.html" rel="nofollow noreferrer">Express</a></p>
  
  <p>I dug a little in the code, and I found two very interesting files :</p>
  
  <pre><code>./myProject/node_modules/express/lib/utils.js
  </code></pre>
  
  <p>and better :</p>
  
  <pre><code>./myProject/node_modules/express/node_modules/connect/lib/utils.js
  </code></pre>
  
  <p>These two files are full of useful functions and I was wondering how to invoke them correctly.</p>
  
  <p>As far, in the <code>./myProject/app.js</code>, that's what I do:</p>
  
  <pre><code>var express = require('express')
    , resource = require('express-resource')
    , mongoose = require('mongoose')
    , expresstUtils =
        require('./node_modules/express/lib/utils.js');
    , connectUtils =
        require('./node_modules/express/node_modules/connect/lib/utils.js');
  </code></pre>
  
  <p>But I found it a little clumsy, and what about my others files?</p>
  
  <p>e.g., here is one of my routes:</p>
  
  <pre><code>myResources = app.resource(
                  'myresources',
                  require('./routes/myresources.js'));
  </code></pre>
  
  <p>and here is the content of <code>myresources.js</code>:</p>
  
  <pre><code>exports.index = function(req, res)
  {
    res.render('./myresources.jade', { title: 'My Resources' });
  };
  
  exports.show = function(req, res)
  {
    fonction resourceIsWellFormatted(param)
    {
      // Here is some code to determine whether the resource requested
      // match with the required format or not
      // return true if the format is ok
      // return false if not
    }
  
    if (resourceIsWellFormatted(req.params['myresources']))
    {
      // render the resource
    }
    else
    {
      res.send(400); // HEY! what about the nice Connect.badRequest in its utils.js?
    }
  };
  </code></pre>
  
  <p>As you can see in the comment after the <code>res.send(400)</code>, I ask myself if it is possible to use the <code>badRequest</code> function which is in the <code>utils.js</code> file of the Connect module.</p>
  
  <p>What about the nice <code>md5</code> function in the same file?</p>
  
  <p><strong>Do I have to place this hugly call at the start of my <code>myresources.js</code> to use them?:</strong></p>
  
  <pre><code>var connectUtils =
        require('../node_modules/express/node_modules/connect/lib/utils.js');
  </code></pre>
  
  <p><strong>or, is there a more elegant solution (even for the <code>app.js</code>)?</strong></p>
  
  <p>Thank you in advance for your help!</p>