jinaga-server 2.1.8 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authorization/authorization-keystore.d.ts +2 -2
- package/dist/authorization/authorization-keystore.js +10 -10
- package/dist/authorization/authorization-keystore.js.map +1 -1
- package/dist/jinaga-server.d.ts +2 -2
- package/dist/jinaga-server.js +17 -29
- package/dist/jinaga-server.js.map +1 -1
- package/dist/postgres/postgres-keystore.d.ts +2 -1
- package/dist/postgres/postgres-keystore.js +5 -4
- package/dist/postgres/postgres-keystore.js.map +1 -1
- package/dist/postgres/postgres-store.d.ts +4 -1
- package/dist/postgres/postgres-store.js +60 -53
- package/dist/postgres/postgres-store.js.map +1 -1
- package/dist/postgres/specification-result-sql.d.ts +1 -1
- package/dist/postgres/specification-result-sql.js +21 -21
- package/dist/postgres/specification-result-sql.js.map +1 -1
- package/dist/postgres/specification-sql.d.ts +2 -2
- package/dist/postgres/specification-sql.js +19 -19
- package/dist/postgres/specification-sql.js.map +1 -1
- package/dist/postgres/sql.d.ts +1 -1
- package/dist/postgres/sql.js +14 -14
- package/dist/postgres/sql.js.map +1 -1
- package/package.json +2 -2
- package/src/authorization/authorization-keystore.ts +11 -11
- package/src/jinaga-server.ts +26 -40
- package/src/postgres/postgres-keystore.ts +4 -4
- package/src/postgres/postgres-store.ts +61 -53
- package/src/postgres/specification-result-sql.ts +21 -21
- package/src/postgres/specification-sql.ts +19 -19
- package/src/postgres/sql.ts +14 -14
- package/test/postgres/postgresReadSpec.ts +1 -1
- package/test/postgres/postgresSpec.ts +1 -1
- package/test/postgres/postgresSpecificationSpec.ts +1 -1
- package/dist/http/node-http.d.ts +0 -7
- package/dist/http/node-http.js +0 -135
- package/dist/http/node-http.js.map +0 -1
- package/src/http/node-http.ts +0 -115
package/src/http/node-http.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import * as http from "http";
|
|
2
|
-
import * as https from "https";
|
|
3
|
-
import { HttpConnection, HttpResponse } from "jinaga";
|
|
4
|
-
import * as url from "url";
|
|
5
|
-
|
|
6
|
-
export class NodeHttpConnection implements HttpConnection {
|
|
7
|
-
constructor(
|
|
8
|
-
private url: string) {
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
get(path: string): Promise<{}> {
|
|
12
|
-
return new Promise<{}>((resolve, reject) => {
|
|
13
|
-
const { protocol } = url.parse(this.url + path);
|
|
14
|
-
const get = protocol === "https:" ? https.get : http.get;
|
|
15
|
-
let data = "";
|
|
16
|
-
get(this.url + path, response => {
|
|
17
|
-
response.on("data", chunk => {
|
|
18
|
-
data += chunk;
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
response.on("end", () => {
|
|
22
|
-
try {
|
|
23
|
-
const result = JSON.parse(data);
|
|
24
|
-
resolve(result);
|
|
25
|
-
}
|
|
26
|
-
catch (x) {
|
|
27
|
-
reject(x);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}).on("error", err => reject(err));
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
post(tail: string, body: {}, timeoutSeconds: number): Promise<HttpResponse> {
|
|
35
|
-
return new Promise<HttpResponse>((resolve, reject) => {
|
|
36
|
-
const { protocol, host, port, path } = url.parse(this.url + tail);
|
|
37
|
-
const request = protocol === "https:" ? https.request : http.request;
|
|
38
|
-
let response = "";
|
|
39
|
-
const req = request({
|
|
40
|
-
method: "POST",
|
|
41
|
-
host, port, path,
|
|
42
|
-
headers: {
|
|
43
|
-
"Accept": "application/json",
|
|
44
|
-
"Content-Type": "application/json"
|
|
45
|
-
},
|
|
46
|
-
timeout: timeoutSeconds * 1000
|
|
47
|
-
}, res => {
|
|
48
|
-
res.on("data", chunk => {
|
|
49
|
-
if (chunk instanceof Buffer) {
|
|
50
|
-
response += chunk.toString();
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
response += chunk;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
res.on("error", err => {
|
|
57
|
-
resolve({
|
|
58
|
-
result: "failure",
|
|
59
|
-
error: err.message
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
res.on("end", () => {
|
|
63
|
-
if (res.statusCode === 403) {
|
|
64
|
-
reject(response);
|
|
65
|
-
}
|
|
66
|
-
else if (!res.statusCode || res.statusCode>= 400) {
|
|
67
|
-
resolve({
|
|
68
|
-
result: "retry",
|
|
69
|
-
error: response
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
else if (res.statusCode === 201) {
|
|
73
|
-
resolve({
|
|
74
|
-
result: "success",
|
|
75
|
-
response: {}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
else if (isJsonResult(res.headers["content-type"])) {
|
|
79
|
-
try {
|
|
80
|
-
const json = JSON.parse(response);
|
|
81
|
-
resolve({
|
|
82
|
-
result: "success",
|
|
83
|
-
response: json
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
catch (x) {
|
|
87
|
-
reject(x);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
reject(response);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
req.on("error", err => {
|
|
97
|
-
resolve({
|
|
98
|
-
result: "failure",
|
|
99
|
-
error: err.message
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
req.write(JSON.stringify(body));
|
|
104
|
-
req.end();
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function isJsonResult(contentType: string | undefined) {
|
|
110
|
-
if (!contentType) {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
const json = contentType.split(";").indexOf("application/json");
|
|
114
|
-
return json >= 0;
|
|
115
|
-
}
|