couch-init2
Advanced tools
Comparing version 2.1.8 to 2.2.0
11
index.js
@@ -23,3 +23,3 @@ const bluebird = require('bluebird') | ||
} | ||
if (!(typeof designDocFolder === 'string')) { | ||
if (typeof designDocFolder !== 'string') { | ||
msg = 'expected an string as designDocFolder path' | ||
@@ -35,4 +35,4 @@ return bluebird.reject(new Error(msg)) | ||
return bluebird.all(dbsList.map(initDb)) | ||
.then(res => ({ ok: true })) | ||
return bluebird.props(dbsList.reduce(aggregateInitDb(initDb), {})) | ||
.then(operations => ({ ok: true, operations })) | ||
.catch(err => { | ||
@@ -46,1 +46,6 @@ if (err.message === 'Name or password is incorrect.') { | ||
} | ||
const aggregateInitDb = initDb => (index, dbData) => { | ||
index[dbData.name] = initDb(dbData) | ||
return index | ||
} |
@@ -15,3 +15,3 @@ const _ = require('inv-loggers') | ||
return ensureDbExistance(nano, db, dbName) | ||
.then(function () { | ||
.tap(function () { | ||
return bluebird.all([ | ||
@@ -27,3 +27,6 @@ syncDesignDocs(db, designDocs), | ||
return db.info() | ||
.then(res => _.success(`${dbName} database: exist`)) | ||
.then(res => { | ||
_.success(`${dbName} database: exist`) | ||
return { created: false } | ||
}) | ||
.catch(create(nano, dbName)) | ||
@@ -35,3 +38,9 @@ } | ||
return nano.db.create(dbName) | ||
.then(_.Log(`${dbName} database: created`)) | ||
.then(([ body, res ]) => { | ||
res.uri = hideBasicAuth(res.uri) | ||
_.log(res, `${dbName} database: created`) | ||
return { created: true } | ||
}) | ||
} | ||
const hideBasicAuth = uri => uri.replace(/(https?):\/\/[^@]+@/, '$1://') |
{ | ||
"name": "couch-init2", | ||
"version": "2.1.8", | ||
"version": "2.2.0", | ||
"description": "Opiniated CouchDB databases initializer", | ||
@@ -9,3 +9,3 @@ "main": "index.js", | ||
"lint": "./node_modules/standard/bin/cmd.js index.js lib/*js", | ||
"prepublish": "npm run lint" | ||
"prepublishOnly": "npm run lint && npm test" | ||
}, | ||
@@ -15,3 +15,3 @@ "author": "maxlath", | ||
"dependencies": { | ||
"bluereq": "^2.1.4", | ||
"bluereq": "^2.1.7", | ||
"inv-loggers": "^3.3.1", | ||
@@ -18,0 +18,0 @@ "nano-blue2": "^0.3.6" |
@@ -42,8 +42,9 @@ # couch-init2 | ||
// returns a promise | ||
.then(function (res) { | ||
.then(res => { | ||
console.log('ok', res.ok) | ||
console.log('operations', res.operations) | ||
// dbs were successfully initialized! | ||
// time to start your server or whatever crazy thing you're building :) | ||
}) | ||
.catch(function (err) { // handle the error }) | ||
.catch(err => { // handle the error }) | ||
``` | ||
@@ -50,0 +51,0 @@ |
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
55308
15
243
56
Updatedbluereq@^2.1.7