nodulator
Version:
Complete NodeJS Framework for Restfull APIs
346 lines (229 loc) • 11.1 kB
HTML
<html>
<head>
<title>Nodulator.ls</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To …</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page_wrapper">
<div id="jump_page">
<a class="source" href="Nodulator.html">
Nodulator.ls
</a>
<a class="source" href="ClientDB.html">
ClientDB.ls
</a>
<a class="source" href="index.html">
index.ls
</a>
<a class="source" href="Resource.html">
Resource.ls
</a>
<a class="source" href="Bus.html">
Bus.ls
</a>
<a class="source" href="Cache.html">
Cache.ls
</a>
<a class="source" href="ChangeWatcher.html">
ChangeWatcher.ls
</a>
<a class="source" href="Debug.html">
Debug.ls
</a>
<a class="source" href="Wrappers.html">
Wrappers.ls
</a>
<a class="source" href="Nodulator.html">
Nodulator.ls
</a>
<a class="source" href="Resource.html">
Resource.ls
</a>
<a class="source" href="Schema.html">
Schema.ls
</a>
<a class="source" href="NModule.html">
NModule.ls
</a>
<a class="source" href="AccountResource.html">
AccountResource.ls
</a>
<a class="source" href="User.html">
User.ls
</a>
<a class="source" href="index.html">
index.ls
</a>
<a class="source" href="Nodulator-Angular.html">
Nodulator-Angular.ls
</a>
<a class="source" href="TaskDirective.html">
TaskDirective.ls
</a>
<a class="source" href="index.html">
index.ls
</a>
<a class="source" href="TaskService.html">
TaskService.ls
</a>
<a class="source" href="main.html">
main.ls
</a>
<a class="source" href="index.html">
index.ls
</a>
<a class="source" href="index.html">
index.ls
</a>
<a class="source" href="Task.html">
Task.ls
</a>
<a class="source" href="index.html">
index.ls
</a>
<a class="source" href="index.html">
index.ls
</a>
<a class="source" href="index.html">
index.ls
</a>
<a class="source" href="index.html">
index.ls
</a>
<a class="source" href="index.html">
index.ls
</a>
<a class="source" href="DOM.html">
DOM.ls
</a>
<a class="source" href="View.html">
View.ls
</a>
<a class="source" href="index.html">
index.ls
</a>
<a class="source" href="Nodulator.html">
Nodulator.ls
</a>
<a class="source" href="Mongo.html">
Mongo.ls
</a>
<a class="source" href="Mysql.html">
Mysql.ls
</a>
<a class="source" href="SqlMem.html">
SqlMem.ls
</a>
<a class="source" href="index.html">
index.ls
</a>
<a class="source" href="Resource.html">
Resource.ls
</a>
<a class="source" href="Request.html">
Request.ls
</a>
<a class="source" href="Route.html">
Route.ls
</a>
<a class="source" href="index.html">
index.ls
</a>
</div>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>Nodulator.ls</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">¶</a>
</div>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">require</span>! {
underscore: _
fs
path
hacktiv
}
<span class="hljs-built_in">global</span> import <span class="hljs-built_in">require</span> \prelude-ls
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">N</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">require</span> \../<span class="hljs-title">Common</span>/<span class="hljs-title">Nodulator</span></span>
config: <span class="hljs-literal">null</span>
consoleMode: <span class="hljs-literal">false</span>
defaultConfig:
db: type: \SqlMem
cache: <span class="hljs-literal">false</span>
modules: {}
port: <span class="hljs-number">3000</span>
isServer: <span class="hljs-literal">true</span>
modules: {}
->
<span class="hljs-keyword">super</span>!
@Init()
Init: <span class="hljs-function">-></span>
@appRoot = path.resolve \.
@libRoot = path.resolve __dirname, \..<span class="hljs-regexp">/../</span>
Resource: <span class="hljs-function">-></span>
@resource = <span class="hljs-built_in">require</span> <span class="hljs-string">'./Resource/Resource'</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> @resource?
<span class="hljs-keyword">super</span> ...
Route: <span class="hljs-built_in">require</span> \./Route/Route
Config: <span class="hljs-function"><span class="hljs-params">(config)</span> -></span>
<span class="hljs-keyword">super</span> ...
<span class="hljs-keyword">return</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> @config.modules?
<span class="hljs-keyword">for</span> name, conf <span class="hljs-keyword">of</span> @config.modules
Module = <span class="hljs-built_in">require</span>(path.resolve @libRoot, <span class="hljs-string">"src/Modules/Nodulator-<span class="hljs-subst">#{capitalize name}</span>"</span>)
@modules[name] = <span class="hljs-keyword">new</span> Module conf
@config.modules[name] <<< @modules[name].config
Reset: <span class="hljs-function"><span class="hljs-params">(done)</span> -></span>
@debug-nodulator.Warn <span class="hljs-string">"Reset"</span>
cache = <span class="hljs-built_in">require</span> \../Common/Helpers/Cache
<span class="hljs-keyword">if</span> cache.client?
cache.Reset!
<span class="hljs-built_in">require</span> \../Common/Helpers/Wrappers .Reset!
<span class="hljs-built_in">require</span> \./Resource/Connectors .Reset!
@inited = {}
@resources = {}
@config = <span class="hljs-literal">null</span>
<span class="hljs-keyword">if</span> @server?
@app = <span class="hljs-literal">null</span>
@server.close()
@server = <span class="hljs-literal">null</span>
@Init()
done() <span class="hljs-keyword">if</span> done?
PostConfig: <span class="hljs-function">-></span>
<span class="hljs-keyword">for</span> name, <span class="hljs-built_in">module</span> <span class="hljs-keyword">of</span> @modules
<span class="hljs-built_in">module</span>.PostConfig!
map (.Init!), values @resources
_ListEndpoints: <span class="hljs-function"><span class="hljs-params">(done)</span> -></span>
endpoints = []
<span class="hljs-keyword">for</span> endpoint <span class="hljs-keyword">in</span> @app._router.stack
<span class="hljs-keyword">if</span> endpoint.route?
res = {}
res[endpoint.route.path] = [key <span class="hljs-keyword">for</span> key <span class="hljs-keyword">of</span> endpoint.route.methods]
endpoints.push res
done(endpoints) <span class="hljs-keyword">if</span> done?
<span class="hljs-function">
<span class="hljs-title">f</span> = (<span class="hljs-params">(...args)</span> -></span>
f.Config {} <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> f.config?
f.Resource.apply f, args) <<<< <span class="hljs-keyword">new</span> N
<span class="hljs-built_in">module</span>.exports = f</pre></div></div>
</li>
</ul>
</div>
</body>
</html>