# pouch-stream-server

> PouchDB stream server

Latest version **0.2.1** (published 2015-11-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install pouch-stream-server
pnpm add pouch-stream-server
yarn add pouch-stream-server
bun add pouch-stream-server
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2015-11-25 |
| First published | 2015-10-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Maintainers | pgte |

## Links

- npm: https://www.npmjs.com/package/pouch-stream-server
- Repository: https://github.com/pgte/pouch-stream-server
- Homepage: https://github.com/pgte/pouch-stream-server#readme
- Issues: https://github.com/pgte/pouch-stream-server/issues
- npm.io page: https://npm.io/package/pouch-stream-server

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^2.2.0
- [xtend](https://npm.io/package/xtend.md) ^4.0.0

## Recent versions

- 0.2.1 (latest) — 2015-11-25
- 0.2.0 — 2015-11-12
- 0.1.3 — 2015-10-26
- 0.1.2 — 2015-10-26
- 0.1.1 — 2015-10-25
- 0.1.0 — 2015-10-24

## README

# pouch-stream-server

[![By](https://img.shields.io/badge/made%20by-yld!-32bbee.svg?style=flat)](http://yld.io/contact?source=github-nock)
[![Build Status](https://secure.travis-ci.org/pgte/pouch-stream-server.svg)](http://travis-ci.org/pgte/pouch-stream-server)

PouchDB stream server. Serves generic PouchDB object streams.

Goes well with [`pouch-remote-stream`](https://github.com/pgte/pouch-remote-stream) on the client.

## PouchDB version

Tested against PouchDB version 5.


## Install

```
$ npm install pouch-server-stream --save
```


## Use

```js
var PouchDB = require('pouchdb');

// Create DB
var db = new PouchDB('mydb');

var PouchStreamServer = require('pouch-stream-server');


// Create a server

var server = PouchStreamServer();

// Add a database to it

server.dbs.add('mydb', db);

// Connect the streams

netServer.on('connection', function(conn) {
  var stream = server.stream();
  stream.pipe(conn).pipe(stream);
});
```

## API

### PouchStreamServer([options])

Creates a Pouch Stream server. Example:

```js
var PouchStreamServer = require('pouch-stream-server');
var server = PouchStreamServer(options);
```

`options` is an optional object with any of the following keys:

* `highWaterMark`: The maximum number of objects to store in the internal buffer before ceasing to read from the underlying resource (when reading) or inducing back-pressure (when writing). Defaults to 16.
 
### server

#### server.dbs.add(dbName, db)

Adds a database that can be addressed by name from the remote stream. Example:

```js
var db = new PouchDB('mydb');
server.dbs.add('myremotedb', db);
```

#### server.stream([options])

Returns a stream to be used to talk to a remote client.

`options` is an optional object with the following optional keys:

* `highWaterMark`: The maximum number of objects to store in the internal buffer before ceasing to read from the underlying resource (when reading) or inducing back-pressure (when writing). Defaults to 16.
* databases: Indication of which databases are allowed to use this stream. Defaults to any. Can be either:
  * a string containing the name of the one allowed database
  * an array of strings containing the names of the allowed databases
  * a filter function that accepts the database name and returns a truthy value if the database is allowed to be used in this stream.

# License

ISC

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