Permalink
Switch branches/tags
660/documentation-build-process first-timers-year fozy81-patch-1 fozy81-patch-2 gr2m-patch-1 greenkeeper/async-2.6.1 greenkeeper/async-pin-2.6.0 greenkeeper/browserify-pin-14.1.0 greenkeeper/good-8.0.0 greenkeeper/good-8.0.1 greenkeeper/good-8.1.0 greenkeeper/good-8.1.1 greenkeeper/h2o2-7.0.0 greenkeeper/h2o2-7.0.1 greenkeeper/h2o2-7.0.2 greenkeeper/h2o2-8.0.0 greenkeeper/h2o2-8.0.1 greenkeeper/h2o2-8.1.0 greenkeeper/h2o2-8.1.1 greenkeeper/h2o2-8.1.2 greenkeeper/hapi-17.0.0 greenkeeper/hapi-17.0.2 greenkeeper/hapi-17.1.0 greenkeeper/hapi-17.1.1 greenkeeper/hapi-17.2.0 greenkeeper/hapi-17.2.1 greenkeeper/hapi-17.2.2 greenkeeper/hapi-17.2.3 greenkeeper/hapi-17.3.0 greenkeeper/hapi-17.3.1 greenkeeper/hapi-17.4.0 greenkeeper/hapi-17.5.0 greenkeeper/inert-5.0.0 greenkeeper/inert-5.0.1 greenkeeper/inert-5.1.0 greenkeeper/lodash-4.17.1 greenkeeper/lodash-4.17.9 greenkeeper/nock-9.0.9 greenkeeper/nock-9.0.10 greenkeeper/nock-9.0.21 greenkeeper/nock-9.0.23 greenkeeper/nock-9.0.24 greenkeeper/nock-9.0.25 greenkeeper/nock-pin-9.0.8 greenkeeper/nock-pin-9.0.22 greenkeeper/npmlog-4.0.1 greenkeeper/proxyquire-2.0.0 greenkeeper/proxyquire-2.0.1 greenkeeper/rc-1.2.4 greenkeeper/rc-pin-1.2.3 greenkeeper/request-2.83.0 greenkeeper/request-2.84.0 greenkeeper/request-2.85.0 greenkeeper/request-2.86.0 greenkeeper/request-2.87.0 greenkeeper/request-pin-2.82.0 greenkeeper/request-pin-2.83.0 greenkeeper/semantic-release-15.0.0 greenkeeper/semantic-release-15.0.1 greenkeeper/semantic-release-15.0.2 greenkeeper/semantic-release-15.0.3 greenkeeper/semantic-release-15.1.2 greenkeeper/semantic-release-15.1.3 greenkeeper/semantic-release-15.1.4 greenkeeper/semantic-release-15.1.5 greenkeeper/semantic-release-15.1.6 greenkeeper/semantic-release-15.1.7 greenkeeper/semantic-release-15.1.8 greenkeeper/semantic-release-15.1.11 greenkeeper/semantic-release-15.3.0 greenkeeper/semantic-release-15.4.1 greenkeeper/semantic-release-15.4.2 greenkeeper/semantic-release-15.4.3 greenkeeper/semantic-release-15.4.4 greenkeeper/semantic-release-15.5.0 greenkeeper/semver-5.5.0 greenkeeper/semver-pin-5.4.1 greenkeeper/tap-12.0.0 greenkeeper/tap-12.0.1 greenkeeper/yargs-8.0.1 greenkeeper/yargs-9.0.1 greenkeeper/yargs-10.0.3 greenkeeper/yargs-10.1.1 greenkeeper/yargs-11.0.0 hoodie-client-legacy legacy master
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
73 lines (62 sloc) 6.97 KB

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