Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

Commit 3963423

Browse files
authored
Merge pull request #345 from cloudant/remove-virtual-hosts
Remove virtual hosts
2 parents 5b1f912 + eead362 commit 3963423

File tree

7 files changed

+1
-186
lines changed

7 files changed

+1
-186
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- [FIXED] Expose `BasePlugin` type in Cloudant client.
33
- [REMOVED] Remove nodejs-cloudant TypeScript type definitions for
44
`db.search`. These definitions are now imported directly from Nano.
5+
- [REMOVED] Removed support for the deprecated Cloudant virtual hosts feature.
56
- [UPGRADED] Using nano==7.1.1 dependency.
67

78
# 2.4.1 (2018-11-12)

README.md

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ This is the official Cloudant library for Node.js.
1818
* [Generate a Cloudant API key](#generate-a-cloudant-api-key)
1919
* [Use a Cloudant API Key](#use-a-cloudant-api-key)
2020
* [CORS](#cors)
21-
* [Virtual Hosts](#virtual-hosts)
2221
* [Cloudant Query](#cloudant-query)
2322
* [Cloudant Search](#cloudant-search)
2423
* [Cloudant Geospatial](#cloudant-geospatial)
@@ -612,33 +611,6 @@ Cloudant account.
612611
613612
See [CORS] for further details.
614613
615-
## Virtual Hosts
616-
617-
If you wish to access your Cloudant domain name (myaccount.cloudant.com) using a
618-
CNAME'd domain name (mysubdomain.mydomain.com) then you can instruct Cloudant to
619-
do so.
620-
621-
- To add a virtual host:
622-
~~~ js
623-
cloudant.add_virtual_host({ host: "mysubdomain.mydomain.com", path: "/mypath"}, function(err, data) {
624-
console.log(err, data);
625-
});
626-
~~~
627-
628-
- To view virtual host configuration:
629-
~~~ js
630-
cloudant.get_virtual_hosts(function(err, data) {
631-
console.log(err, data);
632-
});
633-
~~~
634-
635-
- To delete a virtual host:
636-
~~~ js
637-
cloudant.delete_virtual_host({ host: "mysubdomain.mydomain.com", path: "/mypath"}, function(err, data) {
638-
console.log(err, data);
639-
});
640-
~~~
641-
642614
## Cloudant Query
643615
644616
This feature interfaces with Cloudant's query functionality. See the [Cloudant

cloudant.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -186,34 +186,11 @@ function Cloudant(options, callback) {
186186
body: configuration }, callback);
187187
};
188188

189-
// https://console.bluemix.net/docs/services/Cloudant/api/vhosts.html#listing-virtual-hosts
190-
var get_virtual_hosts = function(callback) { // eslint-disable-line camelcase
191-
return nano.request({path: '_api/v2/user/virtual_hosts',
192-
method: 'get'}, callback);
193-
};
194-
195-
// https://console.bluemix.net/docs/services/Cloudant/api/vhosts.html#creating-a-virtual-host
196-
var add_virtual_host = function(opts, callback) { // eslint-disable-line camelcase
197-
return nano.request({path: '_api/v2/user/virtual_hosts',
198-
method: 'post',
199-
body: opts }, callback);
200-
};
201-
202-
// https://console.bluemix.net/docs/services/Cloudant/api/vhosts.html#deleting-a-virtual-host
203-
var delete_virtual_host = function(opts, callback) { // eslint-disable-line camelcase
204-
return nano.request({path: '_api/v2/user/virtual_hosts',
205-
method: 'delete',
206-
body: opts }, callback);
207-
};
208-
209189
// add top-level Cloudant-specific functions
210190
nano.ping = ping;
211191
nano.get_cors = get_cors; // eslint-disable-line camelcase
212192
nano.set_cors = set_cors; // eslint-disable-line camelcase
213193
nano.generate_api_key = generate_api_key; // eslint-disable-line camelcase
214-
nano.get_virtual_hosts = get_virtual_hosts; // eslint-disable-line camelcase
215-
nano.add_virtual_host = add_virtual_host; // eslint-disable-line camelcase
216-
nano.delete_virtual_host = delete_virtual_host; // eslint-disable-line camelcase
217194

218195
if (callback) {
219196
nano.cc._addPlugins('cookieauth');

test/legacy/api.js

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -962,57 +962,3 @@ function test_gzip() {
962962
});
963963
});
964964
}
965-
966-
describe('Virtual Hosts', function() {
967-
var myHost = `${uuid()}.myhost.com`;
968-
969-
it('supports virtual hosts API - GET /_api/v2/user/virtual_hosts', function(done) {
970-
var mocks = nock(SERVER)
971-
.get('/_api/v2/user/virtual_hosts').reply(200, {'virtual_hosts': []});
972-
973-
var c = Cloudant({ url: SERVER, username: ME, password: PASSWORD, plugins: 'retry' });
974-
c.get_virtual_hosts(function(er, d) {
975-
should(er).equal(null);
976-
d.should.be.an.Object;
977-
d.should.have.a.property('virtual_hosts');
978-
d.virtual_hosts.should.be.an.Array;
979-
980-
mocks.done();
981-
done();
982-
});
983-
});
984-
985-
it('supports virtual hosts API - POST /_api/v2/user/virtual_hosts', function(done) {
986-
var mocks = nock(SERVER)
987-
.post('/_api/v2/user/virtual_hosts').reply(200, {'ok': true});
988-
989-
var c = Cloudant({ url: SERVER, username: ME, password: PASSWORD, plugins: 'retry' });
990-
c.add_virtual_host({ host: myHost, path: '/mypath'}, function(er, d) {
991-
should(er).equal(null);
992-
d.should.be.an.Object;
993-
d.should.have.a.property('ok');
994-
d.ok.should.be.a.Boolean;
995-
d.ok.should.equal(true);
996-
997-
mocks.done();
998-
done();
999-
});
1000-
});
1001-
1002-
it('supports virtual hosts API - DELETE /_api/v2/user/config/virtual_hosts', function(done) {
1003-
var mocks = nock(SERVER)
1004-
.delete('/_api/v2/user/virtual_hosts').reply(200, { 'ok': true });
1005-
1006-
var c = Cloudant({ url: SERVER, username: ME, password: PASSWORD, plugins: 'retry' });
1007-
c.delete_virtual_host({ host: myHost, path: '/mypath'}, function(er, d) {
1008-
should(er).equal(null);
1009-
d.should.be.an.Object;
1010-
d.should.have.a.property('ok');
1011-
d.ok.should.be.a.Boolean;
1012-
d.ok.should.be.equal(true);
1013-
1014-
mocks.done();
1015-
done();
1016-
});
1017-
});
1018-
});

test/legacy/readme-examples.js

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -314,59 +314,6 @@ describe('CORS #db', function() {
314314
});
315315
});
316316

317-
describe('Virtual Hosts', function() {
318-
var mocks;
319-
after(function() { mocks.done(); });
320-
before(function() {
321-
mocks = nock(SERVER)
322-
.post('/_api/v2/user/virtual_hosts')
323-
.reply(200, {ok: true})
324-
.get('/_api/v2/user/virtual_hosts')
325-
.reply(200, { virtual_hosts: [ [ 'mysubdomain.mydomain.com', '/mypath' ] ] })
326-
.delete('/_api/v2/user/virtual_hosts')
327-
.reply(200, {ok: true});
328-
});
329-
330-
var cloudant;
331-
before(function() {
332-
var Cloudant = require('@cloudant/cloudant');
333-
cloudant = Cloudant({url: SERVER, username: ME, password: process.env.cloudant_password, plugins: 'retry'});
334-
});
335-
336-
it('Example 1', function(done) {
337-
cloudant.add_virtual_host({ host: 'mysubdomain.mydomain.com', path: '/mypath'}, function(err, data) {
338-
console.log(err, data);
339-
if (err) {
340-
return done(err);
341-
}
342-
data.should.have.a.property('ok').which.is.equal(true);
343-
done();
344-
});
345-
});
346-
347-
it('Example 2', function(done) {
348-
cloudant.get_virtual_hosts(function(err, data) {
349-
console.log(err, data);
350-
if (err) {
351-
return done(err);
352-
}
353-
data.should.have.a.property('virtual_hosts').which.is.an.Array;
354-
done();
355-
});
356-
});
357-
358-
it('Example 3', function(done) {
359-
cloudant.delete_virtual_host({ host: 'mysubdomain.mydomain.com', path: '/mypath'}, function(err, data) {
360-
console.log(err, data);
361-
if (err) {
362-
return done(err);
363-
}
364-
data.should.have.a.property('ok').which.is.equal(true);
365-
done();
366-
});
367-
});
368-
});
369-
370317
describe('Cloudant Query #db', function() {
371318
var mocks;
372319
before(function() {

types/index.d.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,6 @@ declare namespace cloudant {
100100
[key: string]: any;
101101
}
102102

103-
interface VirtualHost {
104-
host: string;
105-
path: string;
106-
}
107-
108103
// Server Scope
109104
// ============
110105

@@ -113,21 +108,12 @@ declare namespace cloudant {
113108
use(db: string): DocumentScope<any>;
114109
scope(db: string): DocumentScope<any>;
115110

116-
// https://console.bluemix.net/docs/services/Cloudant/api/vhosts.html#creating-a-virtual-host
117-
add_virtual_host(virtualHost: VirtualHost, callback?: Callback<any>): Promise<any>;
118-
119-
// https://console.bluemix.net/docs/services/Cloudant/api/vhosts.html#deleting-a-virtual-host
120-
delete_virtual_host(virtualHost: VirtualHost, callback?: Callback<any>): Promise<any>;
121-
122111
// https://console.bluemix.net/docs/services/Cloudant/api/authorization.html#api-keys
123112
generate_api_key(callback?: Callback<ApiKey>): Promise<any>;
124113

125114
// https://console.bluemix.net/docs/services/Cloudant/api/cors.html#reading-the-cors-configuration
126115
get_cors(callback?: Callback<any>): Promise<any>;
127116

128-
// https://console.bluemix.net/docs/services/Cloudant/api/vhosts.html#listing-virtual-hosts
129-
get_virtual_hosts(callback?: Callback<any>): Promise<any>;
130-
131117
// https://console.bluemix.net/docs/services/Cloudant/api/account.html#ping
132118
ping(callback?: Callback<any>): Promise<any>;
133119

types/tests.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,6 @@ instance.set_cors(cors).then((data) => {});
6262
instance.get_cors((error, data) => {});
6363
instance.get_cors().then((data) => {});
6464

65-
const virtualHost: cloudant.VirtualHost = {
66-
host: 'www.example.com',
67-
path: 'the-path'
68-
};
69-
70-
instance.add_virtual_host(virtualHost, (error, resp) => {});
71-
instance.add_virtual_host(virtualHost).then((resp) => {});
72-
73-
instance.get_virtual_hosts((error, hosts) => {});
74-
instance.get_virtual_hosts().then((hosts) => {});
75-
76-
instance.delete_virtual_host(virtualHost, (error, resp) => {});
77-
instance.delete_virtual_host(virtualHost).then((resp) => {});
78-
7965
/*
8066
* Document Scope
8167
*/

0 commit comments

Comments
 (0)