hapi-datify
your datify-friendly hapi plugin.
how
> npm install hapi-datify
use hapi-datify as a plugin for hapi. For example, if you use hapi cli tool (or composer), put it in your config file:
{
"servers": [
{
"host": "localhost",
"port": 8000,
"options": {
"labels": ["api", "nasty"]
}
}
],
"plugins": {
"hapi-datify": {
"routesToDatifyRegEx": "^/books&"
}
}
}
The example above will datify only the /books route, meaning, it will datify
request.payload
, request.query
.
why
see datify#why.
For example, you could:
pack.route({ method: 'POST', path: '/books', handler: function(request){
books.insert(request.payload, function(err, documents){
request.reply("ok\n");
});
}
});
pack.route({ method: 'GET', path: '/books', handler: function(request){
books.find({ publishedAt: { $gte: request.query.from } }, function(err, books){
request.reply({results: books});
});
}
});
test
> npm install
> make test-cov