Using Hoodie as hapi plugin

Here is an example usage of Hoodie as a hapi plugin:

var Hapi = require('hapi')
var hoodie = require('hoodie').register
var PouchDB = require('pouchdb-core')
  .plugin(require('pouchdb-mapreduce'))
  .plugin(require('pouchdb-adapter-memory'))

var server = new Hapi.Server()
server.connection({
  host: 'localhost',
  port: 8000
})

server.register({
  register: hoodie,
  options: { // pass options here
    inMemory: true,
    public: 'dist',
    PouchDB: PouchDB
  }
}, function (error) {
  if (error) {
    throw error
  }

  server.start(function (error) {
    if (error) {
      throw error
    }

    console.log(('Server running at:', server.info.uri))
  })
})

The available options are

option default description
PouchDB PouchDB constructor. See also custom PouchDB builds
paths.data '.hoodie' Data path
paths.public 'public' Public path
adminPassword Password to login to Admin Dashboard. Login is not possible if adminPassword option is not set
inMemory false If set to true, configuration and other files will not be read from / written to the file system
client {} Hoodie Client options. client.url `` is set based on hapi’s ``server.info.host
account {} Hoodie Account Server options. account.admins, account.secret and account.usersDb are set based on db option above
store {} Hoodie Store Server options. store.couchdb, store.PouchDB are set based on db option above. ``store.hooks.onPreAuth` ` is set to bind user authentication for Hoodie Account to Hoodie Store
plugins [] Array of npm names or paths of locations containing plugins. See also Hoodie plugins docs
app {} App specific options for plugins