Comparing version 5.8.0 to 5.9.0
@@ -1019,3 +1019,7 @@ "use strict"; | ||
ping(timeout) { | ||
return this._pool.ping(timeout); | ||
let auth = undefined; | ||
if (typeof this._options.username === "string") { | ||
auth = `${this._options.username}:${this._options.password || ""}`; | ||
} | ||
return this._pool.ping(timeout, "/ping", auth); | ||
} | ||
@@ -1022,0 +1026,0 @@ /** |
@@ -127,3 +127,3 @@ /// <reference types="node" /> | ||
*/ | ||
ping(timeout: number, path?: string): Promise<IPingStats[]>; | ||
ping(timeout: number, path?: string, auth?: string | undefined): Promise<IPingStats[]>; | ||
/** | ||
@@ -130,0 +130,0 @@ * Makes a request and calls back with the IncomingMessage stream, |
@@ -181,3 +181,3 @@ "use strict"; | ||
*/ | ||
ping(timeout, path = "/ping") { | ||
ping(timeout, path = "/ping", auth = undefined) { | ||
const todo = []; | ||
@@ -191,3 +191,8 @@ setToArray(this._hostsAvailable) | ||
return todo.push(new Promise((resolve) => { | ||
const req = request(Object.assign({ hostname: url.hostname, method: "GET", path, port: Number(url.port), protocol: url.protocol, timeout }, host.options), once((res) => { | ||
const headers = {}; | ||
if (typeof auth !== "undefined") { | ||
const encodedAuth = Buffer.from(auth).toString("base64"); | ||
headers["Authorization"] = `Basic ${encodedAuth}`; | ||
} | ||
const req = request(Object.assign({ hostname: url.hostname, method: "GET", path, port: Number(url.port), protocol: url.protocol, timeout, headers: headers }, host.options), once((res) => { | ||
resolve({ | ||
@@ -194,0 +199,0 @@ url, |
{ | ||
"name": "influx", | ||
"version": "5.8.0", | ||
"version": "5.9.0", | ||
"description": "InfluxDB Client", | ||
@@ -47,6 +47,6 @@ "main": "./lib/src/index.js", | ||
"@types/node": "^14.0.24", | ||
"@types/sinon": "^9.0.4", | ||
"@types/sinon": "^10.0.0", | ||
"@types/sinon-chai": "^3.2.4", | ||
"awesome-typescript-loader": "5.2.1", | ||
"chai": "4.3.3", | ||
"chai": "4.3.4", | ||
"coveralls": "^3.1.0", | ||
@@ -58,3 +58,3 @@ "esdoc": "1.1.0", | ||
"json-loader": "0.5.7", | ||
"karma": "^6.0.0", | ||
"karma": "^6.3.2", | ||
"karma-chrome-launcher": "^3.1.0", | ||
@@ -71,9 +71,9 @@ "karma-mocha": "^2.0.1", | ||
"prettier": "^2.0.5", | ||
"puppeteer": "^8.0.0", | ||
"semantic-release": "^17.1.1", | ||
"sinon": "^9.0.2", | ||
"puppeteer": "^9.0.0", | ||
"semantic-release": "^17.4.2", | ||
"sinon": "^10.0.0", | ||
"sinon-chai": "^3.5.0", | ||
"stream-http": "github:node-influx/stream-http", | ||
"ts-node": "^9.0.0", | ||
"typescript": "^4.0.0", | ||
"typescript": "^4.0.2", | ||
"webpack": "^4.43.0" | ||
@@ -80,0 +80,0 @@ }, |
157715
4299