UNPKG

expresser

Version:

A ready-to-use platform for Node.js web apps, built on top of Express.

214 lines (133 loc) 8.16 kB
<!DOCTYPE html> <html> <head> <title>index.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="public/stylesheets/normalize.css" /> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div class="container"> <div class="page"> <div class="header"> <h1>index.coffee</h1> <div class="toc"> <h3>Table of Contents</h3> <ol> <li> <a class="source" href="index.html"> index.coffee </a> </li> <li> <a class="source" href="app.html"> app.coffee </a> </li> <li> <a class="source" href="cron.html"> cron.coffee </a> </li> <li> <a class="source" href="database.html"> database.coffee </a> </li> <li> <a class="source" href="downloader.html"> downloader.coffee </a> </li> <li> <a class="source" href="events.html"> events.coffee </a> </li> <li> <a class="source" href="firewall.html"> firewall.coffee </a> </li> <li> <a class="source" href="imaging.html"> imaging.coffee </a> </li> <li> <a class="source" href="logger.html"> logger.coffee </a> </li> <li> <a class="source" href="mailer.html"> mailer.coffee </a> </li> <li> <a class="source" href="settings.html"> settings.coffee </a> </li> <li> <a class="source" href="sockets.html"> sockets.coffee </a> </li> <li> <a class="source" href="utils.html"> utils.coffee </a> </li> </ol> </div> </div> <h2 id="expresser">EXPRESSER</h2> <p>A platform and template for Node.js web apps, built on top of Express. If you need help, check the project page at <a href="http://expresser.codeplex.com">http://expresser.codeplex.com</a>.</p> <div class='highlight'><pre> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Expresser</span></span></pre></div> <p>Settings.</p> <div class='highlight'><pre> <span class="hljs-attribute">settings</span>: <span class="hljs-built_in">require</span> <span class="hljs-string">"./lib/settings.coffee"</span></pre></div> <p>Expresser modules.</p> <div class='highlight'><pre> <span class="hljs-attribute">app</span>: <span class="hljs-built_in">require</span> <span class="hljs-string">"./lib/app.coffee"</span> <span class="hljs-attribute">cron</span>: <span class="hljs-built_in">require</span> <span class="hljs-string">"./lib/cron.coffee"</span> <span class="hljs-attribute">database</span>: <span class="hljs-built_in">require</span> <span class="hljs-string">"./lib/database.coffee"</span> <span class="hljs-attribute">downloader</span>: <span class="hljs-built_in">require</span> <span class="hljs-string">"./lib/downloader.coffee"</span> <span class="hljs-attribute">events</span>: <span class="hljs-built_in">require</span> <span class="hljs-string">"./lib/events.coffee"</span> <span class="hljs-attribute">firewall</span>: <span class="hljs-built_in">require</span> <span class="hljs-string">"./lib/firewall.coffee"</span> <span class="hljs-attribute">imaging</span>: <span class="hljs-built_in">require</span> <span class="hljs-string">"./lib/imaging.coffee"</span> <span class="hljs-attribute">logger</span>: <span class="hljs-built_in">require</span> <span class="hljs-string">"./lib/logger.coffee"</span> <span class="hljs-attribute">mailer</span>: <span class="hljs-built_in">require</span> <span class="hljs-string">"./lib/mailer.coffee"</span> <span class="hljs-attribute">sockets</span>: <span class="hljs-built_in">require</span> <span class="hljs-string">"./lib/sockets.coffee"</span> <span class="hljs-attribute">utils</span>: <span class="hljs-built_in">require</span> <span class="hljs-string">"./lib/utils.coffee"</span></pre></div> <p>Expose 3rd party modules.</p> <div class='highlight'><pre> <span class="hljs-attribute">libs</span>: <span class="hljs-attribute">async</span>: <span class="hljs-built_in">require</span> <span class="hljs-string">"async"</span> <span class="hljs-attribute">lodash</span>: <span class="hljs-built_in">require</span> <span class="hljs-string">"lodash"</span> <span class="hljs-attribute">moment</span>: <span class="hljs-built_in">require</span> <span class="hljs-string">"moment"</span></pre></div> <p>Helper to init all modules. Load settings first, then Logger, then general modules, and finally the App. The <code>options</code> can have properties to be passed to the <code>init</code> of each module. @param [Object] options Options to be passed to each init module. @option options [Object] app Pass options to the App init. @option options [Object] database Pass options to the Database init. @option options [Object] logger Pass options to the Logger init. @option options [Object] mailer Pass options to the Mailer init.</p> <div class='highlight'><pre> <span class="hljs-attribute">init</span>: <span class="hljs-function"><span class="hljs-params">(options)</span> =&gt;</span> <span class="hljs-property">@logger</span>.init options?.logger <span class="hljs-property">@database</span>.init options?.database <span class="hljs-property">@mailer</span>.init options?.mailer</pre></div> <p>App must be the last thing to be started! The Firewall and Sockets modules are initiated inside the App.</p> <div class='highlight'><pre> <span class="hljs-property">@app</span>.init options?.app</pre></div> <h2 id="singleton-implementation">Singleton implementation</h2> <div class='highlight'><pre>Expresser.<span class="hljs-function"><span class="hljs-title">getInstance</span> = -&gt;</span> <span class="hljs-property">@instance</span> = <span class="hljs-keyword">new</span> Expresser() <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> <span class="hljs-property">@instance</span>? <span class="hljs-keyword">return</span> <span class="hljs-property">@instance</span> <span class="hljs-built_in">module</span>.<span class="hljs-built_in">exports</span> = <span class="hljs-built_in">exports</span> = Expresser.getInstance()</pre></div> <div class="fleur">h</div> </div> </div> </body> </html>