Comparing version
@@ -160,2 +160,6 @@ /// <reference types="node" /> | ||
placeholders?: Record<string, string | number>; | ||
/** | ||
* Execute a query as a HTTP GET or POST request | ||
*/ | ||
method?: "GET" | "POST"; | ||
} | ||
@@ -162,0 +166,0 @@ export interface IParseOptions { |
@@ -19,2 +19,3 @@ "use strict"; | ||
const grammar = require("./grammar"); | ||
const querystring = require("querystring"); | ||
const pool_1 = require("./pool"); | ||
@@ -1002,3 +1003,3 @@ const results_1 = require("./results"); | ||
params: JSON.stringify(placeholders), | ||
})); | ||
}, options.method, true)); | ||
} | ||
@@ -1043,8 +1044,22 @@ /** | ||
*/ | ||
_getQueryOpts(params, method = "GET") { | ||
return { | ||
method, | ||
path: "/query", | ||
query: Object.assign({ p: this._options.password, u: this._options.username }, params), | ||
_getQueryOpts(params, method = "GET", partOfBody = false) { | ||
const authCredentials = { | ||
u: this._options.username, | ||
p: this._options.password, | ||
}; | ||
if (method === "POST" && partOfBody) { | ||
return { | ||
method, | ||
path: "/query", | ||
query: authCredentials, | ||
body: querystring.stringify(params), | ||
}; | ||
} | ||
else { | ||
return { | ||
method, | ||
path: "/query", | ||
query: Object.assign(Object.assign({}, authCredentials), params) | ||
}; | ||
} | ||
} | ||
@@ -1051,0 +1066,0 @@ /** |
@@ -244,5 +244,5 @@ "use strict"; | ||
} | ||
const req = request(Object.assign({ headers: { | ||
"content-length": options.body ? Buffer.from(options.body).length : 0, | ||
}, hostname: host.url.hostname, method: options.method, path, port: Number(host.url.port), protocol: host.url.protocol, timeout: this._timeout }, host.options), once((res) => { | ||
const req = request(Object.assign({ headers: Object.assign({ "content-length": options.body ? Buffer.from(options.body).length : 0 }, (options.body && options.path === "/query" | ||
? { "Content-Type": "application/x-www-form-urlencoded" } | ||
: {})), hostname: host.url.hostname, method: options.method, path, port: Number(host.url.port), protocol: host.url.protocol, timeout: this._timeout }, host.options), once((res) => { | ||
res.setEncoding("utf8"); | ||
@@ -249,0 +249,0 @@ if (res.statusCode >= 500) { |
{ | ||
"name": "influx", | ||
"version": "5.9.7", | ||
"version": "5.10.0", | ||
"description": "InfluxDB Client", | ||
@@ -19,3 +19,3 @@ "main": "./lib/src/index.js", | ||
"test:ci": "npm-run-all clean test:unit test:integrate build:dist && istanbul cover _mocha --report lcovonly -- lib/test/unit/*.test.js", | ||
"test:unit": "mocha --require ts-node/register test/unit/*.test.ts", | ||
"test:unit": "mocha --require ts-node/register --timeout 20000 test/unit/*.test.ts", | ||
"test:watch": "mocha -R min --watch --require ts-node/register test/unit/*.test.ts", | ||
@@ -45,3 +45,3 @@ "semantic-release": "semantic-release" | ||
"@types/chai": "^4.2.11", | ||
"@types/freeport": "1.0.22", | ||
"@types/freeport": "1.0.24", | ||
"@types/mocha": "^10.0.0", | ||
@@ -63,12 +63,12 @@ "@types/node": "^18.0.0", | ||
"karma-mocha-reporter": "2.2.5", | ||
"karma-sourcemap-loader": "0.3.8", | ||
"karma-sourcemap-loader": "0.4.0", | ||
"karma-webpack": "^5.0.0-alpha.5", | ||
"lodash": "4.17.21", | ||
"mocha": "^10.0.0", | ||
"node-fetch": "3.3.0", | ||
"mocha": "^11.1.0", | ||
"node-fetch": "3.3.2", | ||
"npm-run-all": "4.1.5", | ||
"open-cli": "^7.0.0", | ||
"prettier": "^2.3.0", | ||
"puppeteer": "^19.0.0", | ||
"semantic-release": "^20.0.0", | ||
"open-cli": "^8.0.0", | ||
"prettier": "^3.4.2", | ||
"puppeteer": "^24.1.1", | ||
"semantic-release": "^24.2.1", | ||
"sinon": "^15.0.0", | ||
@@ -75,0 +75,0 @@ "sinon-chai": "^3.5.0", |
{ | ||
"extends": ["config:base", ":preserveSemverRanges", ":disableDependencyDashboard"] | ||
"extends": [ | ||
"config:base", | ||
":preserveSemverRanges", | ||
":disableDependencyDashboard" | ||
] | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
160523
0.86%43
2.38%4331
0.53%