瀏覽代碼

Renaming...

Adam Ierymenko 10 年之前
父節點
當前提交
ecb1ee8e0d
共有 3 個文件被更改,包括 20 次插入20 次删除
  1. 11 11
      js/zt1-api-client/index.js
  2. 3 3
      js/zt1-api-client/package.json
  3. 6 6
      js/zt1-api-client/test.js

+ 11 - 11
js/zt1-api-client/index.js

@@ -2,14 +2,14 @@
 
 var request = require('request');
 
-function ZT1Client(url,authToken)
+function ZT1ApiClient(url,authToken)
 {
 	this.url = url;
 	this.authToken = authToken;
 }
 
 // Generate new ZeroTier identity -- mostly for testing
-ZT1Client.prototype.newIdentity = function(callback)
+ZT1ApiClient.prototype.newIdentity = function(callback)
 {
 	request({
 		url: this.url + 'newIdentity',
@@ -27,7 +27,7 @@ ZT1Client.prototype.newIdentity = function(callback)
 	});
 }
 
-ZT1Client.prototype._jsonGet = function(getPath,callback)
+ZT1ApiClient.prototype._jsonGet = function(getPath,callback)
 {
 	request({
 		url: this.url + getPath,
@@ -44,7 +44,7 @@ ZT1Client.prototype._jsonGet = function(getPath,callback)
 	});
 };
 
-ZT1Client.prototype.status = function(callback)
+ZT1ApiClient.prototype.status = function(callback)
 {
 	request({
 		url: this.url + 'controller',
@@ -77,27 +77,27 @@ ZT1Client.prototype.status = function(callback)
 	}.bind(this));
 };
 
-ZT1Client.prototype.getNetworks = function(callback)
+ZT1ApiClient.prototype.getNetworks = function(callback)
 {
 	this._jsonGet('network',callback);
 };
 
-ZT1Client.prototype.getPeers = function(callback)
+ZT1ApiClient.prototype.getPeers = function(callback)
 {
 	this._jsonGet('peer',callback);
 };
 
-ZT1Client.prototype.listControllerNetworks = function(callback)
+ZT1ApiClient.prototype.listControllerNetworks = function(callback)
 {
 	this._jsonGet('controller/network',callback);
 };
 
-ZT1Client.prototype.getControllerNetwork = function(nwid,callback)
+ZT1ApiClient.prototype.getControllerNetwork = function(nwid,callback)
 {
 	this._jsonGet('controller/network/' + nwid,callback);
 };
 
-ZT1Client.prototype.saveControllerNetwork = function(network,callback)
+ZT1ApiClient.prototype.saveControllerNetwork = function(network,callback)
 {
 	if ((typeof network.nwid !== 'string')||(network.nwid.length !== 16))
 		return callback(new Error('Missing required field: nwid'),null);
@@ -153,8 +153,8 @@ ZT1Client.prototype.saveControllerNetwork = function(network,callback)
 	});
 };
 
-ZT1Client.prototype.getControllerNetworkMember = function(nwid,address,callback) {
+ZT1ApiClient.prototype.getControllerNetworkMember = function(nwid,address,callback) {
 	this._jsonGet('controller/network/' + nwid + '/member/' + address,callback);
 };
 
-exports.ZT1Client = ZT1Client;
+exports.ZT1ApiClient = ZT1ApiClient;

+ 3 - 3
js/zt1-api-client/package.json

@@ -1,7 +1,7 @@
 {
-  "name": "nodejs-zt1-client",
-  "version": "1.0.0",
-  "description": "ZeroTier One Network Virtualization Service JSON API Client",
+  "name": "zt1-api-client",
+  "version": "0.0.1",
+  "description": "ZeroTier One JSON API Client",
   "main": "index.js",
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1"

+ 6 - 6
js/zt1-api-client/test.js

@@ -1,24 +1,24 @@
-var ZT1Client = require('./index.js').ZT1Client;
+var ZT1ApiClient = require('./index.js').ZT1ApiClient;
 
-var zt1c = new ZT1Client('http://127.0.0.1:9993/','5d6181b71fae2684f9cc64ed');
+var zt1 = new ZT1ApiClient('http://127.0.0.1:9993/','5d6181b71fae2684f9cc64ed');
 
-zt1c.status(function(err,status) {
+zt1.status(function(err,status) {
 	if (err)
 		console.log(err);
 	else console.log(status);
 
-	zt1c.getNetworks(function(err,networks) {
+	zt1.getNetworks(function(err,networks) {
 		if (err)
 			console.log(err);
 		else console.log(networks);
 
-		zt1c.getPeers(function(err,peers) {
+		zt1.getPeers(function(err,peers) {
 			if (err)
 				console.log(err);
 			else console.log(peers);
 
 			if (status.controller) {
-				zt1c.saveControllerNetwork({
+				zt1.saveControllerNetwork({
 					nwid: status.address + 'dead01',
 					name: 'test network',
 					private: true