Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
35 lines (32 sloc) 10.9 KB
<!DOCTYPE html> <html> <head> <title>server.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="server.html"> server.js </a> <a class="source" href="settings.html"> settings.js </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> server.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <pre><code>easteregg.in - where you go to get your website's easter eggs
Copyright (c) 2011 Nick Baugh (niftylettuce@gmail.com)
MIT Licensed
</code></pre> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>Built with <a href="http://expressling.com/">Expressling</a></p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <ul>
<li>Maintainer: <a href="https://twitter.com/#!/niftylettuce">@niftylettuce</a></li>
<li>Twitter: <a href="https://twitter.com/#!/eastereggin">@eastereggin</a></li>
<li>Facebook: <a href="https://www.facebook.com/eastereggin">https://www.facebook.com/eastereggin</a></li>
<li>Website: <a href="http://easteregg.in/">http://easteregg.in/</a></li>
<li>Github: <a href="https://github.com/niftylettuce/expressling/">https://github.com/niftylettuce/expressling/</a></li>
</ul> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <h1>Expressling</h1> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <h2>Express</h2> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">express</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;express&#39;</span><span class="p">)</span>
<span class="p">,</span> <span class="nx">app</span> <span class="o">=</span> <span class="nx">express</span><span class="p">.</span><span class="nx">createServer</span><span class="p">()</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <h2>Common</h2> </td> <td class="code"> <div class="highlight"><pre> <span class="p">,</span> <span class="nx">fs</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;fs&#39;</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <h2>Config</h2>
<p>Based on your project's needs, you should configure <code>package.json</code>
accordingly to the <a href="http://npmjs.org">npm</a> packages used.</p>
<ul>
<li><a href="http://wiki.commonjs.org/wiki/Packages/1.0">http://wiki.commonjs.org/wiki/Packages/1.0</a></li>
</ul> </td> <td class="code"> <div class="highlight"><pre> <span class="p">,</span> <span class="nx">config</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./config.json&#39;</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-9"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-9">&#182;</a> </div> <h2>Settings</h2> </td> <td class="code"> <div class="highlight"><pre> <span class="p">,</span> <span class="nx">settings</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./settings&#39;</span><span class="p">)</span></pre></div> </td> </tr> <tr id="section-10"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-10">&#182;</a> </div> <h2>Environment</h2> </td> <td class="code"> <div class="highlight"><pre> <span class="p">,</span> <span class="nx">env</span> <span class="o">=</span> <span class="nx">process</span><span class="p">.</span><span class="nx">env</span><span class="p">.</span><span class="nx">NODE_ENV</span> <span class="o">||</span> <span class="s1">&#39;development&#39;</span>
<span class="p">,</span> <span class="nx">port</span> <span class="o">=</span> <span class="nx">process</span><span class="p">.</span><span class="nx">env</span><span class="p">.</span><span class="nx">PORT</span> <span class="o">||</span> <span class="nx">config</span><span class="p">[</span><span class="nx">env</span><span class="p">].</span><span class="nx">port</span></pre></div> </td> </tr> <tr id="section-11"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-11">&#182;</a> </div> <h1>Load settings</h1> </td> <td class="code"> <div class="highlight"><pre><span class="nx">settings</span><span class="p">.</span><span class="nx">bootApplication</span><span class="p">(</span><span class="nx">app</span><span class="p">);</span>
<span class="nx">settings</span><span class="p">.</span><span class="nx">bootRoutes</span><span class="p">(</span><span class="nx">app</span><span class="p">);</span>
<span class="nx">settings</span><span class="p">.</span><span class="nx">bootErrorConfig</span><span class="p">(</span><span class="nx">app</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-12"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-12">&#182;</a> </div> <h1>Start server</h1> </td> <td class="code"> <div class="highlight"><pre><span class="nx">app</span><span class="p">.</span><span class="nx">listen</span><span class="p">(</span><span class="nx">port</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">appPort</span> <span class="o">=</span> <span class="nx">port</span> <span class="o">+</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="c1">// stringify that int!</span>
<span class="nx">appEnv</span> <span class="o">=</span> <span class="nx">env</span><span class="p">.</span><span class="nx">toUpperCase</span><span class="p">();</span></pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-13">&#182;</a> </div> <h1>Colorful status</h1> </td> <td class="code"> <div class="highlight"><pre><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">&#39;&#39;</span>
<span class="o">+</span> <span class="s1">&#39;\n EASTEREGG.IN SERVER LISTENING ON PORT &#39;</span><span class="p">.</span><span class="nx">rainbow</span>
<span class="o">+</span> <span class="s2">&quot; &quot;</span><span class="p">.</span><span class="nx">white</span><span class="p">.</span><span class="nx">inverse</span>
<span class="o">+</span> <span class="nx">appPort</span><span class="p">.</span><span class="nx">white</span><span class="p">.</span><span class="nx">inverse</span>
<span class="o">+</span> <span class="s2">&quot; &quot;</span><span class="p">.</span><span class="nx">white</span><span class="p">.</span><span class="nx">inverse</span>
<span class="o">+</span> <span class="s1">&#39; IN &#39;</span><span class="p">.</span><span class="nx">rainbow</span>
<span class="o">+</span> <span class="s2">&quot; &quot;</span><span class="p">.</span><span class="nx">white</span><span class="p">.</span><span class="nx">inverse</span>
<span class="o">+</span> <span class="nx">appEnv</span><span class="p">.</span><span class="nx">white</span><span class="p">.</span><span class="nx">inverse</span>
<span class="o">+</span> <span class="s2">&quot; &quot;</span><span class="p">.</span><span class="nx">white</span><span class="p">.</span><span class="nx">inverse</span>
<span class="o">+</span> <span class="s1">&#39; MODE &#39;</span><span class="p">.</span><span class="nx">rainbow</span>
<span class="p">);</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>