hapi-couchdb-store
CouchDB REST & front-end API
Scope
The goal is to create very simplistic server for static apps, that can store,
synchronise and share data only by secure IDs.
Exposes CouchDB's database & document API* at /api
,
and a pre-initialised PouchDB Hoodie Store
at /store.js
.
*CouchDB is in admin party, sensitive APIs are disabled
Install
npm install --save hapi-couchdb-store
Usage
var Hapi = require('hapi')
var hapiStore = require('hapi-couchdb-store')
server.route({
method: 'GET',
path: '/{param*}',
handler: {
directory: {
path: 'public'
}
}
})
server.register({
register: hapiStore,
options: {
couch: 'http://localhost:5984'
}
}, function (error) {
if (error) throw error
})
server.connection({
port: 8000
})
server.start(function () {
console.log('Server running at %s', server.info.uri)
})
<!DOCTYPE html>
<html>
<head>
<title>My App</title>
</head>
<body>
<script src="/store.js"></script>
<script>
var store = new Store('my-shareable-dbname')
store.add({note: 'hello world!'})
</script>
</body>
</html>
Local setup & tests
git clone git@github.com:hoodiehq/hapi-couchdb-store.git
cd hapi-couchdb-store
npm install
npm test
To start the local dev server, run
npm start
License
MIT