title: Register Helper functions Node.JS + Express
body: <p>Im trying to learn NodeJS and Express. Im using the node-localstorage package to access the localstorage. This works when using the code directly in the function like this</p>
  
  <p><em><strong>routes/social.js</em></strong></p>
  
  <pre><code>exports.index = function(req, res)
  {
       if (typeof localStorage === "undefined" || localStorage === null) 
       {
          var LocalStorage = require('node-localstorage').LocalStorage;
          localStorage = new LocalStorage('./scratch');
       }
  
  localStorage.setItem('myFirstKey', 'myFirstValue');
  console.log(localStorage.getItem('myFirstKey'));
  res.render('social/index', {title: "Start"});
  }
  </code></pre>
  
  <p>But I don't want to write this code over and over again in all my other functions when accessing the localstorage. I want to be able to register a helper function that I can access like </p>
  
  <pre><code> var localStorage = helpers.getLocalStorage
  </code></pre>
  
  <p>or something like that.</p>
  
  <p>How can I do this in NodeJS? I've seen something about app.locals? But how can I access the app object in my routes?</p>