hapi-treeize
v0.2.0
Published
A hapi.js plugin that decorates reply with treeize.
Downloads
11
Maintainers
Readme
hapi-treeize
A hapi.js plugin that decorates reply with Treeize functionality. Requires Node v4+.
Install
npm install hapi-treeize
Info
reply.treeize
accepts three parameters:
- required - the data to be treeized
- optional - route specific Treeize options (otherwise uses the defaults you set in
server.register
OR Treeize defaults if you don't specify any) - optional - a signature for the data
See the Treeize documentation for more information on the options and signature.
Usage
const {Server} = require('hapi')
const HapiTreeize = require('hapi-treeize')
const server = new Server()
server.connection({ port: 8080 })
server.register({
register: HapiTreeize,
options: {} // optional, see Treeize docs
}, (err) => {
if (err) throw err
})
server.route([
{
method: 'GET',
path: '/',
handler: (request, reply) => reply.treeize({ value: 'data' })
}
}
server.start((err) => {
if (err) throw err
})
See more examples in the examples directory.
Tests
npm test