Comparing version 1.1.0 to 1.2.0
@@ -57,3 +57,3 @@ module.exports = Cloudant; | ||
var useragent = "nodejs-cloudant/" + pkg.version + " (Node.js " + process.version + ")"; | ||
var requestDefaults = { headers: { "User-agent": useragent}/*, gzip:true*/ }; | ||
var requestDefaults = { headers: { "User-agent": useragent}, gzip:true }; | ||
if (typeof credentials == "object") { | ||
@@ -172,2 +172,26 @@ if (credentials.requestDefaults) { | ||
}; | ||
// https://docs.cloudant.com/api.html#setting-the-cors-configuration | ||
var set_cors = function(configuration, callback) { | ||
nano.request({path: "_api/v2/user/config/cors", | ||
method: "put", | ||
body: configuration }, callback); | ||
}; | ||
var get_virtual_hosts = function(callback) { | ||
nano.request({path: "_api/v2/user/virtual_hosts", | ||
method: "get"}, callback); | ||
}; | ||
var add_virtual_host = function(opts, callback) { | ||
nano.request({path: "_api/v2/user/virtual_hosts", | ||
method: "post", | ||
body: opts }, callback); | ||
}; | ||
var delete_virtual_host = function(opts, callback) { | ||
nano.request({path: "_api/v2/user/virtual_hosts", | ||
method: "delete", | ||
body: opts }, callback); | ||
}; | ||
@@ -180,2 +204,5 @@ // add top-level Cloudant-specific functions | ||
nano.generate_api_key = generate_api_key; | ||
nano.get_virtual_hosts = get_virtual_hosts; | ||
nano.add_virtual_host = add_virtual_host; | ||
nano.delete_virtual_host = delete_virtual_host; | ||
@@ -182,0 +209,0 @@ if (callback) { |
@@ -7,3 +7,3 @@ { | ||
"repository": "git://github.com/cloudant/nodejs-cloudant", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"author": "Jason Smith <jason@cloudant.com>", | ||
@@ -22,3 +22,3 @@ "contributors": [ | ||
"debug": "^2.2.0", | ||
"nano": "6.1.3" | ||
"nano": "6.1.4" | ||
}, | ||
@@ -25,0 +25,0 @@ "devDependencies": { |
@@ -16,2 +16,3 @@ # Cloudant Node.js Client | ||
* [CORS](#cors) | ||
* [Virtual Hosts](#virtual-hosts) | ||
* [Cloudant Query](#cloudant-query) | ||
@@ -184,7 +185,7 @@ * [Cloudant Search](#cloudant-search) | ||
- [Database functions](https://github.com/dscape/nano#database-functions) | ||
- [Document functions](https://github.com/dscape/nano#document-functions) | ||
- [Multipart functions](https://github.com/dscape/nano#multipart-functions) | ||
- [Attachment functions](https://github.com/dscape/nano#attachments-functions) | ||
- [View and Design functions](https://github.com/dscape/nano#views-and-design-functions) | ||
- [Database functions](https://github.com/apache/couchdb-nano#database-functions) | ||
- [Document functions](https://github.com/apache/couchdb-nano#document-functions) | ||
- [Multipart functions](https://github.com/apache/couchdb-nano#multipart-functions) | ||
- [Attachment functions](https://github.com/apache/couchdb-nano#attachments-functions) | ||
- [View and Design functions](https://github.com/apache/couchdb-nano#views-and-design-functions) | ||
@@ -243,10 +244,9 @@ This library adds documentation for the following: | ||
security = { | ||
cloudant: { | ||
nobody: [] | ||
fred : [ '_reader', '_writer', '_admin', '_replicator' ], | ||
isdaingialkyciffestontsk: [ '_reader', '_writer' ] | ||
} | ||
}; | ||
cloudant.set_security( database, security, function(er, result) { | ||
var my_database = cloudant.db.use(db); | ||
my_database.set_security(security, function(er, result) { | ||
if (er) | ||
@@ -265,4 +265,4 @@ throw er | ||
var db = "my_database", | ||
cloudant.view_security( database, function(er, result) { | ||
var my_database = cloudant.db.use(db); | ||
my_database.get_security(function(er, result) { | ||
if (er) | ||
@@ -315,3 +315,3 @@ throw er | ||
console.log(err, data); | ||
}; | ||
}); | ||
~~~ | ||
@@ -324,3 +324,3 @@ | ||
console.log(err, data); | ||
}; | ||
}); | ||
~~~ | ||
@@ -333,3 +333,3 @@ | ||
console.log(err, data); | ||
}; | ||
}); | ||
~~~ | ||
@@ -350,2 +350,29 @@ | ||
## Virtual Hosts | ||
If you wish to access your Cloudant domain name (myaccount.cloudant.com) using a CNAME'd domain name (mysubdomain.mydomain.com) then you can | ||
instruct Cloudant to do so. | ||
e.g. add a virtual host | ||
~~~ js | ||
cloudant.add_virtual_host({ host: "mysubdomain.mydomain.com", path: "/mypath"}, function(err, data) { | ||
console.log(err, data); | ||
}); | ||
~~~ | ||
e.g. view virtual host configuration | ||
~~~ js | ||
cloudant.get_virtual_hosts(function(err, data) { | ||
console.log(err, data); | ||
}); | ||
~~~ | ||
or delete a virtual host | ||
~~~ js | ||
cloudant.delete_virtual_host({ host: "mysubdomain.mydomain.com", path: "/mypath"}, function(err, data) { | ||
console.log(err, data); | ||
}); | ||
~~~ | ||
## Cloudant Query | ||
@@ -735,3 +762,3 @@ | ||
* [Nano Library](https://github.com/dscape/nano) | ||
* [Nano Library](https://github.com/apache/couchdb-nano) | ||
* [Cloudant Documentation](https://docs.cloudant.com/) | ||
@@ -738,0 +765,0 @@ * [Cloudant Query](https://docs.cloudant.com/cloudant_query.html) |
@@ -630,1 +630,71 @@ /** | ||
}); | ||
describe('Gzip header tests', function() { | ||
var server = null; | ||
before(function(done) { | ||
server = require("http").createServer(function(request, response) { | ||
response.writeHead(200, {"Content-Type": "application/json"}); | ||
response.end(JSON.stringify(request.headers)); | ||
}).listen(8080); | ||
done(); | ||
}); | ||
it('checks that the library is providing "I accept compression" headers', function(done) { | ||
var cc = Cloudant("http://localhost:8080"); | ||
var db = cc.db.use("justtesting"); | ||
db.get("justtesting2", function(er, data) { | ||
should(er).equal(null); | ||
data.should.be.an.Object; | ||
data.should.have.a.property("accept-encoding"); | ||
data["accept-encoding"].should.be.a.String; | ||
data["accept-encoding"].should.equal("gzip"); | ||
done(); | ||
}); | ||
}); | ||
after(function(done) { | ||
server.close(); | ||
done(); | ||
}); | ||
}); | ||
describe('Virtual Hosts', function() { | ||
it('supports virtual hosts API - GET /_api/v2/user/virtual_hosts', function(done) { | ||
nock(SERVER).get('/_api/v2/user/virtual_hosts').reply(200, {"virtual_hosts": []}); | ||
var c = Cloudant({account:ME, password:PASSWORD}); | ||
c.get_virtual_hosts(function(er, d) { | ||
should(er).equal(null); | ||
d.should.be.an.Object; | ||
d.should.have.a.property("virtual_hosts"); | ||
d.virtual_hosts.should.be.an.Array; | ||
done(); | ||
}); | ||
}); | ||
it('supports virtual hosts API - POST /_api/v2/user/virtual_hosts', function(done) { | ||
nock(SERVER).post('/_api/v2/user/virtual_hosts').reply(200, {"ok": true}); | ||
var c = Cloudant({account:ME, password:PASSWORD}); | ||
c.add_virtual_host({ host: "myhost.com", path:"/mypath"}, function(er, d) { | ||
should(er).equal(null); | ||
d.should.be.an.Object; | ||
d.should.have.a.property("ok"); | ||
d.ok.should.be.a.Boolean; | ||
d.ok.should.equal(true); | ||
done(); | ||
}); | ||
}); | ||
it('supports virtual hosts API - DELETE /_api/v2/user/config/virtual_hosts', function(done) { | ||
nock(SERVER).delete('/_api/v2/user/virtual_hosts').reply(200, { "ok": true }); | ||
var c = Cloudant({account:ME, password:PASSWORD}); | ||
c.delete_virtual_host({ host: "myhost.com", path:"/mypath"}, function(er, d) { | ||
should(er).equal(null); | ||
d.should.be.an.Object; | ||
d.should.have.a.property("ok"); | ||
d.ok.should.be.a.Boolean; | ||
d.ok.should.be.equal(true); | ||
done(); | ||
}); | ||
}); | ||
}); |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
77145
876
763
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedasn1@0.1.11(transitive)
+ Addedassert-plus@0.1.5(transitive)
+ Addedasync@0.9.2(transitive)
+ Addedaws-sign2@0.5.0(transitive)
+ Addedbl@0.9.5(transitive)
+ Addedbluebird@2.11.0(transitive)
+ Addedboom@2.10.1(transitive)
+ Addedcaseless@0.9.0(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedcombined-stream@0.0.7(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedcryptiles@2.0.5(transitive)
+ Addedctype@0.5.3(transitive)
+ Addeddelayed-stream@0.0.5(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedfollow@0.12.1(transitive)
+ Addedform-data@0.2.0(transitive)
+ Addedgenerate-function@2.3.1(transitive)
+ Addedgenerate-object-property@1.2.0(transitive)
+ Addedhar-validator@1.8.0(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedhawk@2.3.1(transitive)
+ Addedhoek@2.16.3(transitive)
+ Addedhttp-signature@0.10.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-my-ip-valid@1.0.1(transitive)
+ Addedis-my-json-valid@2.20.6(transitive)
+ Addedis-property@1.0.2(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedjsonpointer@5.0.1(transitive)
+ Addedmime-db@1.12.0(transitive)
+ Addedmime-types@2.0.14(transitive)
+ Addednano@6.1.4(transitive)
+ Addednode-uuid@1.4.8(transitive)
+ Addedoauth-sign@0.6.0(transitive)
+ Addedqs@2.4.2(transitive)
+ Addedreadable-stream@1.0.34(transitive)
+ Addedrequest@2.55.0(transitive)
+ Addedsntp@1.0.9(transitive)
+ Addedstring_decoder@0.10.31(transitive)
+ Addedstringstream@0.0.6(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)
+ Addedtldts@6.1.64(transitive)
+ Addedtldts-core@6.1.64(transitive)
+ Addedtough-cookie@5.0.0(transitive)
+ Addedtunnel-agent@0.4.3(transitive)
+ Addedxtend@4.0.2(transitive)
- Removeddebug@0.7.4(transitive)
- Removedfollow@0.11.4(transitive)
- Removednano@6.1.3(transitive)
Updatednano@6.1.4