-
Notifications
You must be signed in to change notification settings - Fork 0
temp
Alvin Sebastian edited this page Dec 2, 2013
·
1 revision
Create a controller:
Create new controller from scratch
exports.view = function(req, res) { ... };
exports.view_method = 'get';
exports.view_route = '/view/:id';
exports.view_title = 'View Item';
exports.list = function(req, res) { ... };
...
Extend a built-in controller
var c = require('modex').createController('resource', {model: require('../models/mymodel')});
c.view = function(req, res) { ... };
c.view_method = 'get';
c.view_route = '/view/:id';
c.view_title = 'View Item';
...
module.exports = c;
Export a function to expose helper object
module.exports = function(mod) {
var mymodel = mod.getModel('mymodel');
var c = mod.createController('resource', {model: mymodel});
c.view = function(req, res) { ... };
c.view_method = 'get';
c.view_route = '/view/:id';
c.view_title = 'View Item';
...
return c;
}