# @hoodie/store-server

> CouchDB API for data persistence and offline sync

Latest version **3.0.0** (published 2017-03-08) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @hoodie/store-server
pnpm add @hoodie/store-server
yarn add @hoodie/store-server
bun add @hoodie/store-server
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2017-03-08 |
| First published | 2016-03-22 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 11 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 7 |
| Author | The Hoodie Community and other contributors \| http://hood.ie/ |
| Maintainers | hoodie |
| Keywords | hapi, plugin, couchdb, pouchdb, hoodie |

## Links

- npm: https://www.npmjs.com/package/@hoodie/store-server
- Repository: https://github.com/hoodiehq/hoodie-store-server
- Homepage: https://github.com/hoodiehq/hoodie-store-server#readme
- Issues: https://github.com/hoodiehq/hoodie-store-server/issues
- npm.io page: https://npm.io/package/@hoodie/store-server

## Dependencies (11)

- [boom](https://npm.io/package/boom.md) ^4.0.0
- [h2o2](https://npm.io/package/h2o2.md) ^5.0.0
- [to-id](https://npm.io/package/to-id.md) ^1.0.5
- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [express](https://npm.io/package/express.md) ^4.15.2
- [request](https://npm.io/package/request.md) ^2.80.0
- [express-pouchdb](https://npm.io/package/express-pouchdb.md) ^2.3.6
- [pouchdb-hoodie-api](https://npm.io/package/pouchdb-hoodie-api.md) ^2.0.0
- [@gr2m/hapi-to-express](https://npm.io/package/@gr2m/hapi-to-express.md) 1.2.1-includes-6
- [@hoodie/store-server-api](https://npm.io/package/@hoodie/store-server-api.md) ^2.0.0

## Recent versions

- 3.0.0 (latest) — 2017-03-08
- 2.1.7 — 2016-12-28
- 2.1.6 — 2016-12-04
- 2.1.5 — 2016-09-13
- 2.1.4 — 2016-09-13
- 2.1.3 — 2016-09-12
- 2.1.2 — 2016-09-10
- 2.1.1 — 2016-09-10
- 2.1.0 — 2016-09-10
- 2.0.3 — 2016-08-27
- 2.0.2 — 2016-07-09
- 2.0.1 — 2016-05-29
- 2.0.0 — 2016-03-22
- 1.1.0 — 2016-03-22

## README

# hoodie-store-server

> CouchDB API for data persistence and offline sync

[![Build Status](https://travis-ci.org/hoodiehq/hoodie-store-server.svg?branch=master)](https://travis-ci.org/hoodiehq/hoodie-store-server)
[![Coverage Status](https://coveralls.io/repos/hoodiehq/hoodie-store-server/badge.svg?branch=master)](https://coveralls.io/github/hoodiehq/hoodie-store-server?branch=master)
[![Dependency Status](https://david-dm.org/hoodiehq/hoodie-store-server.svg)](https://david-dm.org/hoodiehq/hoodie-store-server)
[![devDependency Status](https://david-dm.org/hoodiehq/hoodie-store-server/dev-status.svg)](https://david-dm.org/hoodiehq/hoodie-store-server#info=devDependencies)

`hoodie-store-server` is a [Hapi](http://hapijs.com/) plugin that implements
[CouchDB’s Document API](https://wiki.apache.org/couchdb/HTTP_Document_API)
and exposes a [JavaScript API](api) to manage databases, access and replications.

## Example

```js
var Hapi = require('hapi')
var hoodieStore = require('@hoodie/store-server')
var PouchDB = require('pouchdb')

var server = new Hapi.Server()

server.connection({
  port: 8000
})

server.register({
  register: hoodieStore,
  options: {
    PouchDB: PouchDB
  }
}, function (error) {
  if (error) throw error
})


server.start(function () {
  console.log('Server running at %s', server.info.uri)
})
```

## Options

### options.PouchDB

PouchDB constructor. _Required_

```js
options: {
  PouchDB: require('pouchdb-core').plugin('pouchdb-adapter-leveldb')
}
```

If you want connect to a CouchDB, use the `pouchdb-adapter-http` and set
`options.prefix` to the CouchDB url. All requests will be proxied to CouchDB
directly, the PouchDB constructor is only used for [server.plugins.store.api](api)

```js
options: {
  PouchDB: require('pouchdb-core')
    .plugin('pouchdb-adapter-http')
    .defaults({
      prefix: 'http://localhost:5984',
      auth: {
        username: 'admin',
        password: 'secret'
      }
    })
}
```

### options.hooks

Route lifecycle hooks. _Optional_

```js
options: {
  hooks: {
    onPreResponse: onPreResponseHandler,
    onPreAuth: onPreAuthHandler,
    onPostAuth: onPostAuthHandler,
    onPreHandler: onPreHandlerHandler,
    onPostHandler: onPostHandlerHandler,
    onPreResponse: onPreResponseHandler
  }
}
```

See http://hapijs.com/api#request-lifecycle for more information

## Testing

Local setup

```
git clone https://github.com/hoodiehq/hoodie-store-server.git
cd hoodie-store-server
npm install
```

Run all tests and code style checks

```
npm test
```

## Contributing

Have a look at the Hoodie project's [contribution guidelines](https://github.com/hoodiehq/hoodie/blob/master/CONTRIBUTING.md).
If you want to hang out you can join our [Hoodie Community Chat](http://hood.ie/chat/).

## License

[Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0)

---
_Source: https://npm.io/package/@hoodie/store-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
