Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 30 additions & 39 deletions docs/guides/hapi-plugin.rst
Original file line number Diff line number Diff line change
@@ -1,42 +1,33 @@
Using Hoodie as hapi plugin
===========================

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

.. code:: js

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))
})
})
const Hapi = require('@hapi/hapi');
const Hoodie = require('hoodie').register;

const PouchDB = require('pouchdb-core')
.plugin(require('pouchdb-mapreduce'))
.plugin(require('pouchdb-adapter-memory'));

async function start() {
const server = Hapi.server({
host: 'localhost',
port: 8000
});

await server.register({
plugin: Hoodie,
options: {
inMemory: true,
public: 'dist',
PouchDB
}
});

await server.start();
console.log(`Server running at: ${server.info.uri}`);
}

start().catch(err => {
console.error(err);
process.exit(1);
});

The available options are

Expand Down