Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

couch-init2

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

couch-init2 - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

lib/put_security_doc.js

16

index.js
const _ = require('inv-loggers')
const bluebird = require('bluebird')
const nanoBlue = require('nano-blue')
// example:
// dbBaseUrl = 'http://username:password@localhost:5984'
// dbsList = [

@@ -14,8 +19,6 @@ // {

// nano = require('nano-blue')(yourDbUrlIncludingAuth)
module.exports = function (dbsList, designDocFolder, nano) {
module.exports = function (dbBaseUrl, dbsList, designDocFolder) {
var msg
if (!(typeof nano.use === 'function')) {
msg = 'expected an initialized nano-blue object'
if (!/^https?:\/\/\w+:[^@]+@.+/.test(dbBaseUrl)) {
msg = 'expected a db url with username and password'
return bluebird.reject(new Error(msg))

@@ -32,3 +35,4 @@ }

const initDb = require('./lib/init_db')(nano, designDocFolder)
const nano = nanoBlue(dbBaseUrl)
const initDb = require('./lib/init_db')(dbBaseUrl, nano, designDocFolder)

@@ -35,0 +39,0 @@ return bluebird.all(dbsList.map(initDb))

const _ = require('inv-loggers')
const bluebird = require('bluebird')
const putSecurityDoc = require('./put_security_doc')
module.exports = function (nano, designDocFolder) {
module.exports = function (dbBaseUrl, nano, designDocFolder) {
const initDb = function (dbData) {
_.log(dbData, 'initDb')
const name = dbData.name
const dbName = dbData.name
const designDocs = dbData.designDocs
const db = nano.use(name)
const db = nano.use(dbName)
const syncDesignDocs = require('./sync_design_docs')(designDocFolder)
return ensureDbExistance(name, db)
.then(syncDesignDocs.bind(null, db, designDocs))
return ensureDbExistance(dbName, db)
.then(function () {
return bluebird.all([
syncDesignDocs(db, designDocs),
putSecurityDoc(db, dbBaseUrl, dbName)
])
})
}

@@ -14,0 +21,0 @@

{
"name": "couch-init2",
"version": "1.0.1",
"version": "2.0.0",
"description": "Opiniated CouchDB databases initializer",

@@ -14,3 +14,5 @@ "main": "index.js",

"dependencies": {
"inv-loggers": "^3.1.1"
"bluereq": "^1.0.0",
"inv-loggers": "^3.1.1",
"nano-blue": "^0.3.0"
},

@@ -17,0 +19,0 @@ "devDependencies": {

@@ -6,7 +6,6 @@ # couch-init2

**An opiniated CouchDB databases initializer for users of [nano-blue](https://www.npmjs.com/package/nano-blue)** (which is just a bluebird [promisified](http://bluebirdjs.com/docs/api/promisification.html) version of the awesome [nano](https://github.com/dscape/nano))
**An opiniated CouchDB databases initializer**
Takes a list of databases to initialise and their design docs, and make sure that everything is up and running and in sync.
### Installation

@@ -19,6 +18,6 @@

### How To
```javascript
var dbUrl = 'http://username:password@localhost:5984'
var dbsList = [

@@ -42,8 +41,5 @@ {

var designDocFolder = '/path/to/your/design/docs/folder'
// that probably looks like http://localhost:5984 or http://username:password@localhost:5984 with auth
var dbUrl = 'http://username:password@localhost:5984'
// a nano-blue object initialized with your CouchDB url
var nano = require('nano-blue')(dbUrl)
couchInit(dbsList, designDocFolder, nano)
couchInit(dbUrl, dbsList, designDocFolder)
// returns a promise
.then(function (res) {

@@ -56,1 +52,7 @@ // dbs were successfully initialized!

```
### Actions
* create databases if missing
* create or update design documents
* create [security documents](http://docs.couchdb.org/en/1.6.1/api/database/security.html) if missing

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc