couchdb_utilities
Advanced tools
Comparing version 1.0.6 to 1.0.7-prerelease
84
index.js
@@ -11,11 +11,67 @@ exports.printMsg = function() { | ||
// server Utilities | ||
exports.validateConnection = function ( couchURL ) { | ||
var couchDBURL = couchURL; | ||
Obj = this.returnObjfromURL(couchDBURL); | ||
if ( Obj.responseCode == 200 ) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
}; | ||
exports.getServerVersion = function ( couchURL ) { | ||
var couchDBURL = couchURL; | ||
Obj = this.returnObjfromURL(couchDBURL); | ||
if ( Obj.responseCode == 200 ) { | ||
return JSON.parse( Obj.responseString).version; | ||
} else { | ||
return false; | ||
} | ||
}; | ||
exports.responseDuration = function ( couchURL ) { | ||
var couchDBURL = couchURL; | ||
Obj = this.returnObjfromURL(couchDBURL); | ||
if ( Obj.responseCode == 200 ) { | ||
return Obj.duration; | ||
} else { | ||
return false; | ||
} | ||
}; | ||
// database Utilities | ||
exports.listDatabases = function ( couchURL ) { | ||
var couchDBURL = couchURL + "/" + "_all_dbs"; | ||
Obj = this.returnObjfromURL(couchDBURL); | ||
return JSON.parse ( Obj.responseString); | ||
return JSON.parse( Obj.responseString); | ||
}; | ||
exports.databaseExists = function ( couchURL, databaseName ) { | ||
var couchDBURL = couchURL + "/" + databaseName; | ||
Obj = this.returnObjfromURL(couchDBURL); | ||
if ( Obj.responseCode == 404 ) { | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
}; | ||
exports.createDatabase = function ( couchURL, databaseName ) { | ||
var couchDBURL = couchURL + "/" + databaseName; | ||
Obj = this.callURL("PUT", couchDBURL, null ); | ||
if ( Obj.responseCode == 200 || Obj.responseCode == 201 ) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
}; | ||
// Internal Methods | ||
exports.returnObjfromURL = function ( URL ) { | ||
@@ -33,5 +89,5 @@ | ||
var responseString = response.getBody('utf8'); | ||
var responseString = response.body.toString('utf8'); | ||
returnObj.responseCode = response.getBody('utf8'); | ||
returnObj.responseCode = response.statusCode; | ||
returnObj.responseString = responseString; | ||
@@ -42,1 +98,23 @@ | ||
}; | ||
exports.callURL = function ( Method, URL, Payload ) { | ||
var returnObj = {} | ||
var syncRequest = require('sync-request'); | ||
var jsonPayload = { json: Payload }; | ||
returnObj.startTime = (new Date).getTime(); | ||
var response = syncRequest(Method, URL, jsonPayload ); | ||
returnObj.endTime = (new Date).getTime(); | ||
returnObj.duration = returnObj.endTime - returnObj.startTime; | ||
returnObj.duration = returnObj.duration + " milliseconds" | ||
var responseString = response.body.toString('utf8'); | ||
returnObj.responseCode = response.statusCode; | ||
returnObj.responseString = responseString; | ||
return returnObj; | ||
}; |
{ | ||
"name": "couchdb_utilities", | ||
"version": "v1.0.6", | ||
"version": "v1.0.7prerelease", | ||
"description": "This package will help you sync the design documents from one couchdb to another", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -10,21 +10,34 @@ # Module under development. | ||
### Core | ||
#### Verify Inputs | ||
#### Validate connection - Source | ||
#### Validate Connection - target | ||
#### Get list of Dbs in the Source | ||
### Server Utilities | ||
#### Validate the input connection string | ||
``` | ||
var Boolean = couchUtils.validateConnection ( "http://0.0.0.0:5984" ) ); | ||
``` | ||
#### Validate the input connection string | ||
``` | ||
var String = couchUtils.getServerVersion ( "http://0.0.0.0:5984" ) ); | ||
``` | ||
#### Validate the input connection string | ||
``` | ||
var String = couchUtils.responseDuration ( "http://0.0.0.0:5984" ) ); | ||
``` | ||
### Database Utilities | ||
#### Get list of databases | ||
``` | ||
console.log( couchUtils.listDatabases( "http://0.0.0.0:5984" ) ); | ||
[ | ||
"_replicator", | ||
"_users", | ||
"test2" | ||
] | ||
var Array = couchUtils.listDatabases( "http://0.0.0.0:5984" ) ); | ||
``` | ||
#### Check if a database exists in the target | ||
``` | ||
var Boolean = couchUtils.databaseExists( "http://0.0.0.0:5984", "test" ) ); | ||
``` | ||
#### Create a database in target | ||
``` | ||
var Boolean = couchUtils.createDatabase( "http://0.0.0.0:5984", "test" ) ); | ||
``` | ||
#### Check if the view exist | ||
#### Check db in the target | ||
#### Create db in target | ||
### Design Docs | ||
@@ -31,0 +44,0 @@ #### Create view |
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
4634
88
48
2