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

cloudant

Package Overview
Dependencies
Maintainers
3
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudant - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

29

cloudant.js

@@ -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) {

4

package.json

@@ -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();
});
});
});
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