nk
v0.3.2
Published
nodakwaeri (nk): A simple, yet powerful, and fully-featured cross-platform application framework for Node.js.
Downloads
23
Maintainers
Readme
nodakwaeri ( nk )
A simple, yet powerful, and fully-featured cross-platform application framework for Node.js.
Unless you are only planning on using a few pieces of nodakwaeri and intend to use custom facilities, it's recommended that you install nodakwaeri via the nk-mvc or nk-xrm project template. There is more in-depth documentation available for nk-mvc which covers all aspects of the framework, and provides an excellent starting place for any nodakwaeri application. The nk-xrm repository may also provide more advanced resources, examples, and documentation for working with nodakwaeri as progress is made.
To install the nodakwaeri module, use npm as shown below in either terminal/shell or command prompt. Be sure to have Node.js and Git installed, with the latter's root directory in your systems environment path.
path_to_app/> npm install nk
var nk = require( 'nk' );
nk = new nk();
...
Below describes some general usage of nodakwaeri. Browsing the source will also prove to be a good way to get to know the nk toolset, as well as visiting the nodakwaeri wiki @ Github.
When one desires to check the type of a variable, consider the following snippet:
...
if( nk.type( obj ) !== 'function' )
{
// Do what you will
}
...
When extending objects and/or arrays, they can be of either type. Default behaviors occur when extending like types.
Objects:
var obj1 = { 'First': 1, 'Second': 2, 'Fourth': 4 };
var piece3 = { 'Third': 3 };
obj1 = nk.extend( obj1, piece3 );
for( var prop in obj1 )
{
console.log( 'Key:' + prop + ', Value: ' + obj1[prop] + '.' );
}
/> Key: First, Value: 1.
/> Key: Second, Value: 2.
/> Key: Fourth, Value: 4.
/> Key: Third, Value: 3.
var arr1 = [ 1, 2, 4 ];
var piece3 = [ 3 ];
arr1 = nk.extend( arr1, piece3 );
for( var prop in arr1 )
{
console.log( 'Key:' + prop + ', Value: ' + arr1[prop] + '.' );
}
/> Key: 0, Value: 1.
/> Key: 1, Value: 2.
/> Key: 2, Value: 4.
/> Key: 3, Value: 3.
Arrays with Objects (Non-default):
var arr1 = [ 1, 2, 4 };
var piece3 = { '3': 3 };
arr1 = nk.extend( arr1, piece3, false );
for( var prop in arr1 )
{
console.log( 'Key:' + prop + ', Value: ' + obj1[prop] + '.' );
}
/> Key: 0, Value: 1.
/> Key: 1, Value: 2.
/> Key: 2, Value: 4.
/> Key: 3, Value: 3.
Extending an Object with an array works the same as the above, but has no 'non-default' behavior:
var obj1 = { 'First': 1, 'Second': 2, 'Fourth': 4 };
var piece3 = [ 3 ];
obj1 = nk.extend( obj1, piece3 );
for( var prop in obj1 )
{
console.log( 'Key:' + prop + ', Value: ' + obj1[prop] + '.' );
}
/> Key: First, Value: 1.
/> Key: Second, Value: 2.
/> Key: Fourth, Value: 4.
/> Key: 0, Value: 3.
One of our jQuery favorites is an absolute must:
var obj1 = { 'First': 1, 'Second': 2, 'Fourth': 4 };
var piece3 = { 'Third': 3 };
obj1 = nk.extend( obj1, piece3 );
nk.each
(
obj1,
function( k, v )
{
console.log( 'Key:' + k + ', Value: ' + v + '.' );
}
);
/> Key: First, Value: 1.
/> Key: Second, Value: 2.
/> Key: Fourth, Value: 4.
/> Key: Third, Value: 3.
nodakwaeri also provides all of the facilities one might need to create an application. This includes:
Factory | Purpose --------|-------- Server | Defines and initialises the http server, listening for incoming client connections. Utilizes the session and router factories. Session | Creates and manages all client sessions to provide persistence for the end user. Protects against 'Session Take-over' and 'Session Injection' techniques. Provides tools to the developer for manipulating the session. Router | Detects and processes media requests from the browser and/or routes client requests to the proper controller for further processing. SCJL (Cryptography) | nodakwaeri is bootstrapped with The Stanford Javascript Crypto Library, via their BSD License. Controller | Implements the MVC design pattern. Invokes the derived controller requested. Developers define the application's controllers. Model | Implements the MVC design pattern. Provides the interface to the data integration tools and database object. Developers define the application's models. Renderer | Implements the MVC design pattern. Constructs XHTML for the response to the client, provides a fully featured scripting language for templating, and allows for shared layouts and powerful organization. Developers define the application's views. HTML | Provides tools for generating commonly used HTML5 controls in Accessible Rich Internet Applications (ARIA).
As a side note, by default nk-mvc makes uses of nodamysql (nk-mysql) as a database provider, and uses Bootstrap(which includes Normalize) and jQuery via CDN.
nodakwaeri is designed to work out of the box using a config file from the root of your application:
var nk = require( 'nk' ),
config = require( './config' ),
app = new nk( config );
app.init();
// Your application is now running...
Feel free to fork the repository and submit pull requests. Browse any of our other repositories as well MMOD @ Github.
You may also contribute by making a donation