title: Node.js/Express application architecture
body: <p>In PHP applications I'm able to create classes hierarchy</p>
  
  <pre><code>class UserController  extends Controller {
      public function __constructor(){
          //..
      }
  }
  
  class LoggedUserController  extends UserController  {
      protected $_loggedUser;
      public function __constructor(){
          if( empty($_SESSION['user']) ){
              die('Access denied');
          }
          else{
              $this-&gt;_loggedUser = $_SESSION['user'];
          }
      }
  }
  
  class MessagesController  extends LoggedUserController {
      public function action_get_all(){
          // here I can use $this-&gt;_loggedUser and be sure that it is not empty
          //  Something like that:
          $messages = ORM::factory('messages')-&gt;where('user_id', '=', $this-&gt;_loggedUser-&gt;id)-&gt;find_all();
      }
  }
  </code></pre>
  
  <p>In the same way I can create class AdminUserController and be sure that controller is not available for non-admin users.</p>
  
  <p>But in Node.js I cannot use this trick since constructors of controolers will be called only once, when app is being loaded.</p>
  
  <p>Maybe there is some way to achive this in Node.js?</p>