quick-mvc
v1.2.0
Published
Quick mvc bootstrap for Express 4.x
Downloads
6
Readme
Quick-MVC
Quick mvc bootstrap for Express 4.x. Similar to Ruby on Rails but a lot more lightweight. :)
Usage
// app.js
var app = require('express')();
var mvc = require('quick-mvc');
// mvc(options) returns an express router that can be used as middleware
app.use(mvc({ verbose: true, view_engine: 'jade' }));
app.listen(3000);
Directory Structure
Internal Views
options.external_views = false
-- app
|-- controllers
| |-- user
| |-- views
| |-- list.jade
| |-- show.jade
| |-- index.js
|-- models
| |-- db.js
|--- app.js
External Views
options.external_views = true
-- app
|-- controllers
| |-- user
| |-- index.js
|-- models
| |-- db.js
|-- views
| |-- user
| |-- list.jade
| |-- show.jade
|--- app.js
Controller
// controller/user/index.js
var db = require('../models/db.js');
exports.list = function (req, res, next) {
res.render('list', { users: db.getUsers() });
}
exports.show = function (req, res, next) {
res.render('show', { user: db.getUser(req.params.id) });
}
Options
{
verbose // if true it will print all the routes it creates
external_views // if true it will use external views vs internal
view_engine // if you want a diffrent view engine defaults to jade
}