title: Plugin system for Node.JS
body: <p>I am currently working on a large application in <a href="http://nodejs.org/" rel="noreferrer">Node.JS</a>, on top of <a href="http://expressjs.com/" rel="noreferrer">Express</a>.</p>
  
  <p>I was hoping to make things plug&amp;play-able, so I started writing my own little plugin-system, whose file structure looks like this:</p>
  
  <pre><code>root/
  |   plugins.json            # configures all plugins
  |   plugins                 # contains all plugins
  |   |   MyPlugin            # contains MyPlugin
  |   |   |   MyPlugin.js     # defines Application hooks for MyPlugin
  |   |   |   ...
  </code></pre>
  
  <p><code>MyPlugin/</code> of course also contains Routes, Controllers, Views, specific resources etc.</p>
  
  <p>The standard hooks that <code>app</code> will call on an instance of <code>MyPlugin</code> are:</p>
  
  <pre><code>moduleInit(app)             # before starting the server or module has been loaded (if server is already running at module load)
  moduleStart(app)            # right after server has been started or not at all
  moduleCleanup(app)          # right before the party ends
  </code></pre>
  
  <p>So far, so good, but now things get more complicated (and they will always only get even more complicated), as I have to consider the sequence of module initialization (as they might attach themselves to the handler stack with <code>use</code>, <code>get</code>, <code>post</code>, etc.), and more...</p>
  
  <p>Since I am still somewhat new to Node and Express, I started having doubts:
  Is there maybe already a good engine out there that does all that? I could not find one, which leads me to believe that this might actually be a bad idea? Maybe there is a more "node"- or "express"- kind of way to do things that I am overlooking?</p>
  
  <p>Thanks for your help!</p>