smuggler

0.1.0 • Public • Published

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: 'jonny@example.com'
		})
	}, 'fullInfo');

	res.render('index', next);
});

To be improved...

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i smuggler

    Weekly Downloads

    3

    Version

    0.1.0

    License

    MIT

    Last publish

    Collaborators

    • ramonfritsch