smuggler
v0.1.0
Published
expressjs route helpers
Downloads
177
Maintainers
Readme
Smuggler
An expressjs middleware to handle with responses in an elegant way
This library is heavily inspired by KeystoneJS's View class.
If you often find yourself struggling with callbacks and middlewares on your routes, this is for you. Smuggler is all about providing a simple api for asyncronous responses.
Getting started
npm install smuggler --save
var express = require('express');
var smuggler = require('smuggler');
var app = express();
app.use(smuggler());
...
Example
app.get('/', function (req, res, next) {
res.on('init', function (cb) {
cb(null, new Date().getTime());
}, 'time');
res.on('get', 'full', function (cb) {
cb(null, {
name: 'John',
email: '[email protected]'
})
}, 'fullInfo');
res.render('index', next);
});
To be improved...