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-mkdb

v2.0.3

Published

Utility to create couchdb databases easier.

Downloads

20

Readme

couchdb-mkdb

Build Status

couchdb-mkdb makes it easy to create databases and stream couchdb's response.

Installation

$ npm i -S couchdb-mkdb

Usage

Express example

This express route creates new databases on every request.

...
app.post('/', (req, res, next) => {
  let name = 'mydb-' + uuid.v1();
  let opts = {

    // `security` is a special option ...
    security: {
      admins: {names: [req.user.name], roles: []},
      members: {names: [], roles: []}
    },

    // ... all other options are passed to the underlaying `request` function.
    // See https://github.com/request/request#requestoptions-callback
    baseUrl: app.get('couchdb'),
    auth: app.get('auth')
  };

  // Use the mkdb utility to create the database
  mkdb(name, opts)
    .on('error', next)
    .on('response', function(response) {

      // For error handling check the statusCode
      if ((response.statusCode / 100 | 0) !== 2) {
        console.log('Database wasn\'t created or security couldn\'t be updated');
      }
      response.pipe(
        res.set(response.headers)
          .status(response.statusCode)
      );
    })
    .on('success', function() {

      // Event 'response' has already been emitted
      console.log('Database successfully created');
    });
});

API

mkdb(name, [opts], callback)

  • name The name of the database
  • opts Optional options object. See below
  • callback Function with the signature fn(error, response)

Available options are:

All other options are passed to the underlaying request() function.

Events

  • error(err) - Emitted on request error
  • errorResponse(res) - deprecated Emitted when couchdb returns a paranormal response. See Update notes
  • response(res) - Emitted when couchdb responds to the last action
  • success - Emitted on success

Tests

$ git clone https://github.com/domachine/node-couchdb-mkdb.git
$ cd node-couchdb-mkdb
$ npm i
$ npm test

Update notes

v2.0

mkdb now uses request as transport engine. Therefore the options you can pass are similar to request's options. See docs.

v1.1

The first version had an 'errorResponse' event. This has now been deprecated. Use the 'response' event instead and check the statusCode.