Skip to content

reedlauber/shack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An Express wrapper library that provides enhanced routing and controller handling.

Installation

$ npm install shack

Use just like express

var shack = require('shack');
var app = shack();

app.get('/', function(req, res){
  res.send('Hello World');
});

app.listen(3000);

Define routes in a dedicated JSON file

{
	"get /users": { "action":"users" },
	"post /users/:id": { "action":"users:update" },
	"put /users/:id": { "action":"users:create" }
}

Define controllers with actions instead of routes

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;

Features

  • 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

About

Node routing and controllers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published