nodeigniterMVC
NodeigniterMVC - an MVC framework for node.js inspired by Codeigniter. It allows custom routing, chaining, and partial view rendering; built-in with helpers, libraries, and a CLI. Fully compatible with Bower.
Dependencies:
- connect
- commander
- connect
CI-based URL structure
http://www.domain.com/[controller]/[function]/[param1]/[param2]/[etc]
Installation
Via NPM:
npm install nodeignitermvc
Creating an app
nodeigniter create <appname>
Running the app
node appjs
Use inside application:
var ni = ;
Customize the autoload in app/config/autoload.js
// currently available helpersthishelpers = 'security''array''url' 'string' 'html' 'form';//or load the helper in the controllerni;//ORni;
Custom routing in app/config/routes.js
// set your custom routes herethisroute =src: '/sign_up' dest: '/main/sign_up' method: 'GET''POST'src: '/sign_in' dest: '/main/sign_in' method: 'GET''POST';
Setting config variables
// config variable settingvar ni = ;//setterni;//gettervar val = ni;
Accessing helpers
// config variable settingvar ni = ;//from url helpernifn;//from html helpernifn;//to view availabe functionsconsole;
Form validation:
// config variable settingvar ni = ;//validation libraryni;//set the rules - same with codeigniternivalidation;//to executeif nivalidationsome+form_input('name', set_value('name'), {class: 'someclass' maxlength: 30}) +}//accessing the request variablesvar username = niinputreq_varsusername;var password = nifn;//you can also use any functions
Loading views--uses the ejs templating system:
// setting the partial pages and render, allows chainingvar ni = ;// file should be located in the views folder under app: app/viewsni;//you can also put the file into a sub folderni;//or thisni;
view exaample app/views/section/header.ejs
=<html lang="en"><head><title>Nodeigniter - Fast and flexible node framework</title>====</head>//use the curly braces= some_function or some vars