https://github.com/gr2m/spawn-pouchdb-server
Configurable per-app pouchdb-server as a drop-in replacement for CouchDB
https://github.com/gr2m/spawn-pouchdb-server
Last synced: about 1 year ago
JSON representation
Configurable per-app pouchdb-server as a drop-in replacement for CouchDB
- Host: GitHub
- URL: https://github.com/gr2m/spawn-pouchdb-server
- Owner: gr2m
- Created: 2015-07-31T19:26:17.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2021-03-05T06:49:21.000Z (over 5 years ago)
- Last Synced: 2024-04-22T13:23:45.287Z (about 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 43.9 KB
- Stars: 27
- Watchers: 29
- Forks: 13
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# spawn-pouchdb-server
> Configurable per-app pouchdb-server as a drop-in replacement for CouchDB
[](https://www.npmjs.com/package/spawn-pouchdb-server)
[](https://travis-ci.org/gr2m/spawn-pouchdb-server)
[](https://coveralls.io/r/gr2m/spawn-pouchdb-server?branch=master)
[](https://david-dm.org/gr2m/spawn-pouchdb-server)
## Motivation
1. Simplify development setup
CouchDB is a fantastic database, but setting it up for local development is not easy, as it also
requires an Erlang runtime environment. Having a built-in PouchDB-Server in our apps will make
CouchDB optional.
2. Isolated CouchDB configurations
Many Apps require couchdb users / admins / security settings etc. Using PouchDB makes it simple
to isolate these in local development. (But if you don't mind the CouchDB dependency,
you can also use [node-multicouch](https://github.com/gr2m/node-multicouch) for that).
## Usage
```js
// npm install --save spawn-pouchdb-server
var spawnPouchdbServer = require('spawn-pouchdb-server')
spawnPouchdbServer(function (error, server) {
console.log('PouchDB Server stared at localhost:5985/_utils')
server.stop(function () {
console.log('PouchDB Server stopped')
})
})
```
Full example with all options (and default values)
```js
// npm install --save spawn-pouchdb-server
var spawnPouchdbServer = require('spawn-pouchdb-server')
spawnPouchdbServer({
port: 5985,
directory: './.db',
backend: {
name: 'leveldown',
location: './.db'
},
log: {
file: './.db/pouch.log',
level: 'info'
},
config: {
file: './.db/config.json'
},
timeout: 10000, // in ms
verbose: false
}, function (error, server) {
console.log('PouchDB Server stared at localhost:5985/_utils')
})
```
## Options
Option
Description
default
port
Port number where CouchDB API will be exposed
5985
directory
Directory where PouchDB server will store it's files. Also default location for file based levelup back-ends
5985
backend
Either an object with name and location properties (see below), or false for in-memory
see below
backend.name
npm module name of levelup storage back-end
built in leveldown
backend.location
Location option as passed to levelup(location)
"./.db"
log.file
Location of log file. Set to false to disable logging to a file. log.file is an alias for config.log.file. Set to false to not persist logs
"./.db/pouch.log"
log.level
One of debug, info, warning, error, none. log.level is an alias for config.log.level
"info"
config.file
Location of CouchDB-esque config file. Set to false to not persist configuration.
"./.db/config.json"
config.*
All the CouchDB Configuration, e.g. config.admins = {"adminuser": "adminpass"} to fix admin party
timeout
Time to connect to backend in milliseconds
10000
verbose (true/false)
Log status information
false
## Local setup & tests
```bash
git clone git@github.com:gr2m/spawn-pouchdb-server.git
cd spawn-pouchdb-server
npm install
npm test
```
## License
MIT