Skip to content

Commit aa16985

Browse files
authored
Merge pull request #28 from taosdata/fix/xiaolei/3.0-rest-connect-cloud-failed
fix(driver):node-rest 3.0 connect cloud failed for default port
2 parents 94d16f7 + ea4c8eb commit aa16985

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

typescript-rest/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ let options: Options = {
66
user: 'root',
77
passwd: 'taosdata',
88
host: "127.0.0.1",
9-
port: 6041,
109
}
1110
let connect = function connect(option: Options) {
1211
// console.log("index.options:"+JSON.stringify(option));

typescript-rest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tdengine/rest",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"description": "A REST connector for TDengine",
55
"source": "index.ts",
66
"main": "dist/main/index.js",

typescript-rest/src/cursor.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ export class TDengineCursor {
4343
return new Result(res_json);
4444
}
4545

46-
}else if (response.status == 400) {
47-
new Error("invalid parameters.")
48-
}else if (response.status == 401) {
46+
} else if (response.status == 400) {
47+
new Error("invalid parameters.")
48+
} else if (response.status == 401) {
4949
throw new Error("Authentication failed.")
50-
}else if (response.status == 404) {
50+
} else if (response.status == 404) {
5151
throw new Error("interface not exists.")
52-
}else if (response.status == 500) {
52+
} else if (response.status == 500) {
5353
throw new Error("internal error.")
54-
}else if (response.status == 503) {
54+
} else if (response.status == 503) {
5555
throw new Error("insufficient system resource.")
5656
}
5757
throw new Error("http request failed.");

typescript-rest/src/request.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ export class TDResRequest {
3636
} else {
3737
//do nothing
3838
}
39-
url = `${this.uri.scheme}://${this.uri.host}:${this.uri.port}${this.uri.path}`
40-
39+
if (this.uri.port) {
40+
url = `${this.uri.scheme}://${this.uri.host}:${this.uri.port}${this.uri.path}`
41+
} else {
42+
url = `${this.uri.scheme}://${this.uri.host}${this.uri.path}`
43+
}
4144
if (this.uri.query) {
4245
url += '?'
4346
Object.keys(this.uri.query).forEach(
@@ -103,6 +106,7 @@ export class TDResRequest {
103106

104107
request(command: string): Promise<any> {
105108
this._body(command);
109+
//console.log(this._makeUrl());
106110
return fetch(this._makeUrl(), this.options);
107111
}
108112
}

0 commit comments

Comments
 (0)