npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

couchdb-bootstrap

v15.1.0

Published

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

Downloads

1,849

Readme

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