• Stars
    star
    115
  • Rank 305,916 (Top 7 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Bootstrap CouchDB projects: configure, setup security, deploy ddocs and create users.

CouchDB Bootstrap

Bootstrap CouchDB server from CLI or API.

  • set and override /_config
  • create databases (unless existent)
  • create and update database _security objects
  • create and update user accounts
  • create and update design documents
  • create and update replication documents
  • create and update seed documents

CouchDB Bootstrap combines different small tools, which can also be used independently. Each of those tools come has a similar API and is shipped with a CLI:

Directory

Think about CouchDB Bootstrap as a toplevel manager, which reads a directory of databases and optional _config and hands each file over to the appropriate tool:

project/couchdb
├── _config.json
├── _replicator
│   ├── setup-alice.json
│   └── setup-bob.json
├── _users
│   ├── alice.json
│   └── bob.json
├── myapp
│   ├── _design
│   │   └── myapp.js
│   ├── _security.json
│   └── adoc.json
├── myapp-alice
│   ├── doc1.json
│   ├── doc2-commonjs.js
│   └── _security.json
└── myapp-bob
    └── _security.json

In the directory tree above project/couchdb/_config.json is handed to couchdb-configure, project/couchdb/_replicator/setup-alice.json, project/couchdb/myapp/_design/myapp.js project/couchdb/myapp/adoc.json are handed (beside others) to couchdb-push and project/couchdb/myapp-alice/_security.json to couchdb-secure.

Since [email protected] it is possible to provide a configuration object:

{
  'my-db': {
    _security: {
      members: {
        roles: [],
        names: [
          '[email protected]'
        ]
      },
      admins: {
        roles: [],
        names: [
          '[email protected]'
        ]
      }
    },
    mydoc: {
      date: '2018-03-16T19:27:52.361Z',
      title: 'Welcome'
    },
    _design: {
      myapp: {
        views: {
          'by-date': {
            map: function (doc) {
              if ('date' in doc) {
                emit(doc.date, null)
              }
            },
            reduce: '_count'
          }
        }
      }
    }
  },
  _users: {
    alice: {
      _id: 'org.couchdb.user:[email protected]',
      type: 'user',
      roles: [],
      name: '[email protected]',
      password: 'secure'
    }
  }
}

See couchdb-compile for more details about the CouchDB Filesystem Mapping on a document / security object / config level.

API

bootstrap(url, source[, options], callback)
  • url - CouchDB server URL
  • source - bootstrap object or directory holding the bootstrap tree
  • options.index - When set to true, folders are searched for index.js, which, if present, is treated as CommonJS module. Default is false.
  • options.concurrency - Limit number of concurrent requests. Defaults to 100.
  • options.multipart - When set to true, attachments are saved via multipart api. Default is false.
  • options.watch - When set to true, documents are pushed (not _config!) on filesystem change. Default is false.
  • options.mapDbName - Set to object or function to map directories to custom database names
  • callback - called when done with a response object describing the status of all operations.

API Example

var bootstrap = require('couchdb-bootstrap')
bootstrap('http://localhost:5984', 'project/couchdb', function(error, response) {
  // here we go
})

Since 14.2.0 it is possible to provide a configuration object:

var bootstrap = require('couchdb-bootstrap')
var config = {
  'my-db': {
    _design: {
      myapp: {
        views: {
          'by-date': {
            map: function (doc) {
              if ('date' in doc) {
                emit(doc.date, null)
              }
            },
            reduce: '_count'
          }
        }
      }
    }
  }
}

bootstrap('http://localhost:5984', config, function(error, response) {
  //
})

CLI

couchdb-bootstrap URL [SOURCE] [OPTIONS]

Or use the shortcurt cdbb.

When SOURCE is omitted, the current directory will be used. options.index is always true. OPTIONS can be --concurrency, --multipart, --watch or --mapDbName='{"old-name": "new-name"}', see above.

CLI Example

couchdb-bootstrap http://localhost:5984 project/couchdb

Source as CommonJS file:

couchdb-bootstrap http://localhost:5984 bootstrap.js

See test/fixtures/bootstrap.js for an example.

Tests

npm test

More Repositories

1

couchdb-best-practices

Collect best practices around the CouchDB universe.
CSS
320
star
2

backbone-pouch

Backbone PouchDB Adapter
JavaScript
163
star
3

docuri

Rich document ids for CouchDB
JavaScript
103
star
4

puret

Puret is a minimal pure translation library for translating database values for Rails 3.
Ruby
74
star
5

pouch-box

Asymmetric encrypted PouchDB, powered by NaCl's curve25519-xsalsa20-poly1305.
JavaScript
67
star
6

grunt-couch

Build and publish Couchapps and CouchDB design documents with grunt. Simple.
JavaScript
46
star
7

couchdb-push

Deploy CouchDB documents from directory, JSON or CommonJS module.
JavaScript
40
star
8

couchdb-compile

Build CouchDB documents from directory, JSON or CommonJS module
JavaScript
38
star
9

pouch-resolve-conflicts

Assist in CouchDB conflict resolution
JavaScript
34
star
10

quilt

Access CouchDB from filesystem
Ruby
21
star
11

session25519

Derive Curve25519 encryption keys and ed25519 signing keys from username and password via BLAKE2s hash and scrypt.
JavaScript
20
star
12

roy-replicator

Node implementation of CouchDB replicator. For educational purposes.
JavaScript
20
star
13

mouch

Couchapp Purism
Ruby
19
star
14

couchmagick

Couchmagick runs ImageMagicks convert on CouchDB documents. Reliable.
JavaScript
17
star
15

couch-daemon

High-level os daemon API for CouchDB.
JavaScript
14
star
16

webcryptobox-js

Tiny utility library for asymetric encryption via WebCrypto with zero dependencies.
JavaScript
14
star
17

couchdb-worker

A worker module that manages state.
JavaScript
13
star
18

git-relax

Proof of Concept for a sync solution based on Git and Apache CouchDB
Shell
12
star
19

couchdb-configure

Configure CouchDB from file, node module or directory.
JavaScript
12
star
20

http-image-size

Detect image dimensions over http.
JavaScript
10
star
21

hello-gjs-npm

Example application demonstrating the use of Babel and Rollup to create an NPM installable and -runnable Gjs executable from ES2015 project source
JavaScript
10
star
22

couchdb-secure

Write couchdb security object from file or directory.
JavaScript
9
star
23

worker-fetch-tweets

Fetch tweets and store them in a CouchDB.
JavaScript
8
star
24

couch-box

Asymmetric encrypted CouchDB documents, powered by NaCl's curve25519-xsalsa20-poly1305.
JavaScript
7
star
25

massage-couch

Massage CouchDB documents with an os daemon worker.
JavaScript
7
star
26

microcouch-rs

A minimal Pouch-like implementation of a CouchDB compatible embeddable couch. Work in progress.
Rust
5
star
27

multipart-related

Parse `multipart/related` responses in the browser
JavaScript
5
star
28

connect-nano

req.nano, which passes session cookies to CouchDB and back again.
JavaScript
5
star
29

microcouch-js

A minimal Pouch-like implementation of a CouchDB compatible in-browser couch, for educational purpose.
JavaScript
4
star
30

couchdb-ensure

Create database unless it exists.
JavaScript
4
star
31

couch64

Handle base64 encoding and decoding inside CouchDB, eg. in list functions.
JavaScript
4
star
32

webcryptobox-rs

Utility library and CLI for WebCrypto compatible encryption
Rust
4
star
33

webcryptobox

WebCrypto compatible encryption libraries and CLIs
4
star
34

worker-generate-previews

CouchDB worker to generate previews from pdf
JavaScript
4
star
35

worker-generate-thumbnails

CouchDB worker which generates image thumbnails.
JavaScript
3
star
36

couch-daemon-bridge

Use CouchDBs os_daemons with node.
JavaScript
3
star
37

pouchdb-live-query

Provide a view which keeps itself up to date by listening to the changes feed.
JavaScript
3
star
38

global-couch-stream

Readable changes feed stream from all databases
JavaScript
3
star
39

sync-tank

Describing strategies for migrations in a distributed CouchDB world.
CSS
3
star
40

minip

Mini P is a simple database that can replicate with CouchDB.
JavaScript
3
star
41

worker-generate-stills

CouchDB worker which generates stills from videos.
JavaScript
3
star
42

i18n-tools

Tools for merging, collecting and converting i18n translations.
Ruby
3
star
43

couch-nacl-permit

Handle database permits, which encrypts a database key with a session key. For use with couch-box.
JavaScript
2
star
44

couchmagick-stream

Pipe CouchDB documents through ImageMagicks convert.
JavaScript
2
star
45

couchdb-cors-config

JavaScript
2
star
46

coup.js

Tiny script plays client side with CouchDB rewrites, lists and shows.
JavaScript
2
star
47

worker-convert

CouchDB worker which converts images
JavaScript
2
star
48

couchdb-create-index

Create CouchDB index from file or directory.
JavaScript
2
star
49

couchdb-bulk

Pipe line-seperated JSON into CouchDB
JavaScript
2
star
50

worker-fetch-json

A hoodie worker that fetches a remote JSON and inserts it into a document.
JavaScript
2
star
51

couchnacl

Use TweetNaCl.js from inside CouchDB
JavaScript
2
star
52

googlefontcssmerge

Download google font css with different user agents and combine src attributes.
JavaScript
2
star
53

couchdb-global-changes-stream

Multiplexed persisted global couchdb changes stream across all databases.
JavaScript
2
star
54

dimensionist

CouchDB daemon to extract dimensions from image attachments.
JavaScript
2
star
55

rouchdb

Minimal CouchDB compatible database written in Rust.
Rust
2
star
56

googlefontcss64

Download Google fonts and print base64 embedded style definitions.
JavaScript
2
star
57

couchdb-global-changes-rs

A global changes feed CLI in Rust [experimental]
Rust
1
star
58

urs

Ultra Responsive Slider
JavaScript
1
star
59

autoprogettazione-dinamica

JavaScript
1
star
60

tita

Things I Threw Away
HTML
1
star
61

gtk-rs-with-icons-resource

Demo project about how to work with icons and gresources on Rust GTK.
Rust
1
star
62

couchdb-flatpak-example

Example Flatpak application with CouchDB included
Shell
1
star
63

nosta

Skeleton for a small single page application based on dynamic imports
JavaScript
1
star
64

filander

Helps dealing with files and directories
Ruby
1
star
65

grunt-init-couch

Create a Couch project with grunt-init, including Nodeunit unit tests.
JavaScript
1
star
66

lena

Slick minimalistic Content Management System for artists and others.
JavaScript
1
star
67

worker-attachments

General attachments CouchDB worker.
JavaScript
1
star
68

trovebox-uploader

Upload images to trovebox like a pro
Ruby
1
star
69

tfcss

Use Cascading Style Sheets in Ruby.
Ruby
1
star
70

enzo-mari

Enzo Mari's Tavolo Rettangolare in your own dimensions
JavaScript
1
star
71

shnell

Server Setup and Configuration tools
Ruby
1
star