Node MVC framework inspired by Codeigniter

npm install nodeignitermvc
2 downloads in the last week
4 downloads in the last month


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.


  • connect
  • commander
  • connect

CI-based URL structure[controller]/[function]/[param1]/[param2]/[etc]


Via NPM:

npm install nodeignitermvc

Creating an app

nodeigniter create <appname>

Running the app

node app.js

Use inside application:

var ni = require('nodeigniter');

Customize the autoload in app/config/autoload.js

// currently available helpers
this.helpers = ['security','array','url', 'string', 'html', 'form'];

//or load the helper in the controller

ni.load_helper(['array', 'url']);

Custom routing in app/config/routes.js

// set your custom routes here
this.route = [
    {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 setting
var ni = require('nodeigniter');

ni.config('some-name', 'value');

var val = ni.config('some-name');

Accessing helpers

// config variable setting
var ni = require('nodeigniter');

//from url helper

//from html helper

//to view availabe functions

Form validation:

// config variable setting
var ni = require('nodeigniter');

//validation library

//set the rules - same with codeigniter
ni.validation.set_rules('name', 'display', 'required|valid_email|max_length[30]');

//to execute
if ( {
    some function
} else {
    some function

//writing form fields to the view and setting the values

    form_open('') + 
    form_input('name', set_value('name'), {class: 'someclass', maxlength: 30}) + 
    form_submit('submit', 'Submit')

//accessing the request variables

var username = ni.input.req_vars.username;
var password = ni.fn.sha1(ni.input.req_vars.password);

//you can also use any functions

Loading views--uses the ejs templating system:

// setting the partial pages and render, allows chaining

var ni = require('nodeigniter');

// file should be located in the views folder under app: app/views

//you can also put the file into a sub folder

//or this

view exaample app/views/section/header.ejs

{{= doctype('html5') }}
<html lang="en">
        <title>Nodeigniter - Fast and flexible node framework</title>
        {{= link_tag('css/bootstrap.min.css?timestamp='+Number(new Date())) }}
        {{= link_tag('css/custom.css?timestamp='+Number(new Date())) }}
        {{= script_tag('js/jquery-1.4.6.min.js?timestamp='+Number(new Date())) }}
        {{= script_tag('js/jquery.tmpl.js?timestamp='+Number(new Date())) }}

//use the curly braces
{{= some_function or some vars }}
npm loves you