An Express wrapper library that provides enhanced routing and controller handling.
$ npm install shack
var shack = require('shack');
var app = shack();
app.get('/', function(req, res){
res.send('Hello World');
});
app.listen(3000);
{
"get /users": { "action":"users" },
"post /users/:id": { "action":"users:update" },
"put /users/:id": { "action":"users:create" }
}
var ctrl = require('shack').controller('users');
// A default "index" action is always created
ctrl.action('create', function(req, res, success) {
// Save user
User.save({}, function(user) {
success(user);
});
});
modules.exports = ctrl;
- Build on Express
- Elegant, dedicated routing file
- Controller pattern focused on actions instead of specifically http requests
- Sensible defaults for common behaviors
- Easily default whole controllers or actions to JSON
- "before" and "after" handlers for common pre- or post-action behaviors