couch-init2
Advanced tools
Comparing version 1.0.1 to 2.0.0
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52219
10
198
55
3
+ Addedbluereq@^1.0.0
+ Addednano-blue@^0.3.0
+ Addedajv@6.12.6(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.13.2(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedbluebird@2.11.03.7.2(transitive)
+ Addedbluereq@1.0.0(transitive)
+ Addedbrowser-request@0.3.3(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedcloudant-follow@0.17.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddebug@2.6.93.2.7(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addederrs@0.3.2(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedlodash@3.10.1(transitive)
+ Addedlodash.isempty@4.4.0(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedms@2.0.02.1.3(transitive)
+ Addednano@6.4.4(transitive)
+ Addednano-blue@0.3.0(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedpsl@1.15.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqs@6.5.3(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)