-
Notifications
You must be signed in to change notification settings - Fork 0
API Reference
Olivier Wietrich edited this page Mar 30, 2014
·
7 revisions
Create a plumby app.
var plumby = require('plumby');
var app = plumby();
It is a good practice to expose your app in order to reuse it somewhere else:
var plumby = require('plumby');
var app = module.exports = plumby();
Consistent and adaptive interface to use plugins or other apps.
A plugin is a function with the app scope as first argument with some optional options.
app.use(function(ctx, opts){
//do something on app
}, options);
var mail = plumby();
app.use(mail);
or
var mail = plumby();
app.use('mail', mail);
Plumby expose an elegant dependency injector in order to extend or use the same features in different apps:
var plumby = require('plumby');
plumby.inject('foo', {
isFoo : true,
alert : function(){
alert('hello world');
}
});
var app = plumby('foo');
app.alert(); //alert hello world
app.isFoo; //true
var plumby = require('plumby');
//add http request and debug
plumby
.inject('bar')
.use(superagent())
.use(debug());
var app = plumby('bar');
var other = plumby('bar');