0.2.0 • Published 5 years ago

hapi-treeize v0.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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:

  1. required - the data to be treeized
  2. optional - route specific Treeize options (otherwise uses the defaults you set in server.register OR Treeize defaults if you don't specify any)
  3. 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

0.2.0

5 years ago

0.1.0

5 years ago