@bfchain/bnrtc2-client-api
Advanced tools
Comparing version 0.0.2 to 2.0.0-alpha.1
@@ -0,1 +1,2 @@ | ||
import "@bfchain/bnrtc2-client-typings"; | ||
export interface ChannelConnectedEvent { | ||
@@ -28,3 +29,3 @@ channelId: number; | ||
isOnline(address: string): Promise<boolean>; | ||
getServerConfig(): Promise<any>; | ||
getServerConfig(): Promise<Bnrtc2.Bnrtc2ServerConfig>; | ||
addPeers(hosts: string[]): Promise<boolean>; | ||
@@ -31,0 +32,0 @@ delPeers(hosts: string[]): Promise<boolean>; |
@@ -13,2 +13,3 @@ "use strict"; | ||
exports.Bnrtc2Api = void 0; | ||
require("@bfchain/bnrtc2-client-typings"); | ||
const const_1 = require("./const"); | ||
@@ -29,6 +30,6 @@ const global_1 = require("./global#"); | ||
const reqInit = { | ||
method: "GET", | ||
method: 'GET', | ||
headers: { | ||
"Content-Type": "text/plain", | ||
}, | ||
'Content-Type': "text/plain", | ||
} | ||
}; | ||
@@ -78,10 +79,6 @@ return global_1.bnrtc2Global.fetch(url, reqInit); | ||
const url = this._getUrl(this.baseHttpUrl, const_1.API_PATH.HTTP_API_PATH_SERVER_BIND_ADDRESS, { address }); | ||
return this.httpFetch(url) | ||
.then((res) => { | ||
return this.httpFetch(url).then((res) => { | ||
this.httpError(res); | ||
return res.ok; | ||
}) | ||
.catch((e) => { | ||
return this.httpFetchError(e); | ||
}); | ||
}).catch((e) => { return this.httpFetchError(e); }); | ||
}); | ||
@@ -92,10 +89,6 @@ } | ||
const url = this._getUrl(this.baseHttpUrl, const_1.API_PATH.HTTP_API_PATH_SERVER_UNBIND_ADDRESS, { address }); | ||
return this.httpFetch(url) | ||
.then((res) => { | ||
return this.httpFetch(url).then((res) => { | ||
this.httpError(res); | ||
return res.ok; | ||
}) | ||
.catch((e) => { | ||
return this.httpFetchError(e); | ||
}); | ||
}).catch((e) => { return this.httpFetchError(e); }); | ||
}); | ||
@@ -106,10 +99,6 @@ } | ||
const url = this._getUrl(this.baseHttpUrl, const_1.API_PATH.HTTP_API_PATH_SERVER_IS_ONLINE, { address }); | ||
return this.httpFetch(url) | ||
.then((res) => { | ||
return this.httpFetch(url).then((res) => { | ||
this.httpError(res); | ||
return res.ok; | ||
}) | ||
.catch((e) => { | ||
return this.httpFetchError(e); | ||
}); | ||
}).catch((e) => { return this.httpFetchError(e); }); | ||
}); | ||
@@ -122,3 +111,3 @@ } | ||
if (res.ok) { | ||
return yield res.json(); | ||
return res.json(); | ||
} | ||
@@ -132,10 +121,6 @@ throw new Error(`getPeers for ${url} failed ${yield res.text()}`); | ||
const url = this._getUrl(this.baseHttpUrl, const_1.API_PATH.HTTP_API_PATH_SERVER_ADD_PEERS, { hosts }); | ||
return this.httpFetch(url) | ||
.then((res) => { | ||
return this.httpFetch(url).then((res) => { | ||
this.httpError(res); | ||
return res.ok; | ||
}) | ||
.catch((e) => { | ||
return this.httpFetchError(e); | ||
}); | ||
}).catch((e) => { return this.httpFetchError(e); }); | ||
}); | ||
@@ -146,10 +131,6 @@ } | ||
const url = this._getUrl(this.baseHttpUrl, const_1.API_PATH.HTTP_API_PATH_SERVER_DEL_PEERS, { hosts }); | ||
return this.httpFetch(url) | ||
.then((res) => { | ||
return this.httpFetch(url).then((res) => { | ||
this.httpError(res); | ||
return res.ok; | ||
}) | ||
.catch((e) => { | ||
return this.httpFetchError(e); | ||
}); | ||
}).catch((e) => { return this.httpFetchError(e); }); | ||
}); | ||
@@ -162,3 +143,3 @@ } | ||
if (res.ok) { | ||
return yield res.json(); | ||
return res.json(); | ||
} | ||
@@ -165,0 +146,0 @@ throw new Error(`getPeers for ${url} failed ${yield res.text()}`); |
@@ -10,5 +10,5 @@ export declare const DEFAULT_BASE_API_HOSTNAME = "127.0.0.1"; | ||
HTTP_API_PATH_SERVER_GET_PEERS = "/bnrtc2/server/getPeers", | ||
WS_API_PATH_SERVER_CONNECT = "/bnrtc2/server/connect", | ||
HTTP_API_PATH_SERVER_GET_SERVER_CONFIG = "/bnrtc2/server/serverConfig" | ||
HTTP_API_PATH_SERVER_GET_SERVER_CONFIG = "/bnrtc2/server/serverConfig", | ||
WS_API_PATH_SERVER_CONNECT = "/bnrtc2/server/connect" | ||
} | ||
//# sourceMappingURL=const.d.ts.map |
@@ -14,4 +14,4 @@ "use strict"; | ||
API_PATH["HTTP_API_PATH_SERVER_GET_PEERS"] = "/bnrtc2/server/getPeers"; | ||
API_PATH["HTTP_API_PATH_SERVER_GET_SERVER_CONFIG"] = "/bnrtc2/server/serverConfig"; | ||
API_PATH["WS_API_PATH_SERVER_CONNECT"] = "/bnrtc2/server/connect"; | ||
API_PATH["HTTP_API_PATH_SERVER_GET_SERVER_CONFIG"] = "/bnrtc2/server/serverConfig"; | ||
})(API_PATH = exports.API_PATH || (exports.API_PATH = {})); |
{ | ||
"name": "@bfchain/bnrtc2-client-api", | ||
"version": "0.0.2", | ||
"version": "2.0.0-alpha.1", | ||
"main": "./build/index.js", | ||
@@ -8,3 +8,3 @@ "types": "./build/index.d.ts", | ||
"dependencies": { | ||
"@bfchain/bnrtc2-client-typings": "^0.0.2", | ||
"@bfchain/bnrtc2-client-typings": "^2.0.0-alpha.1", | ||
"@bfcs/util-evt": "^0.0.1-alpha.2" | ||
@@ -11,0 +11,0 @@ }, |
10233
231
+ Added@bfchain/bnrtc2-buffer-typings@2.0.16(transitive)
+ Added@bfchain/bnrtc2-client-typings@2.0.16(transitive)
- Removed@bfchain/bnrtc2-buffer-typings@0.0.2(transitive)
- Removed@bfchain/bnrtc2-client-typings@0.0.2(transitive)