@nestia/fetcher 1.5.1 → 1.5.2-dev.20230802-2
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/lib/Fetcher.d.ts +1 -0
- package/lib/Fetcher.js +15 -11
- package/lib/Fetcher.js.map +1 -1
- package/lib/HttpError.d.ts +3 -3
- package/lib/HttpError.js.map +1 -1
- package/package.json +1 -1
- package/src/Fetcher.ts +18 -8
- package/src/HttpError.ts +8 -2
package/lib/Fetcher.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { Primitive } from "./Primitive";
|
|
|
15
15
|
* @author Jeongho Nam - https://github.com/samchon
|
|
16
16
|
*/
|
|
17
17
|
export declare class Fetcher {
|
|
18
|
+
static fetch(connection: IConnection, encrypted: Fetcher.IEncrypted, method: "HEAD", path: string): Promise<void>;
|
|
18
19
|
/**
|
|
19
20
|
* Fetch function for the `GET` methods.
|
|
20
21
|
*
|
package/lib/Fetcher.js
CHANGED
|
@@ -100,17 +100,17 @@ var Fetcher = /** @class */ (function () {
|
|
|
100
100
|
function Fetcher() {
|
|
101
101
|
}
|
|
102
102
|
Fetcher.fetch = function (connection, encrypted, method, path, input, stringify) {
|
|
103
|
-
var _a, _b, _c, _d;
|
|
103
|
+
var _a, _b, _c, _d, _e;
|
|
104
104
|
return __awaiter(this, void 0, void 0, function () {
|
|
105
105
|
var headers, init, url, response, text, content, ret;
|
|
106
|
-
return __generator(this, function (
|
|
107
|
-
switch (
|
|
106
|
+
return __generator(this, function (_f) {
|
|
107
|
+
switch (_f.label) {
|
|
108
108
|
case 0:
|
|
109
109
|
if (encrypted.request === true || encrypted.response === true)
|
|
110
110
|
if (connection.encryption === undefined)
|
|
111
111
|
throw new Error("Error on nestia.Fetcher.encrypt(): the encryption password has not been configured.");
|
|
112
112
|
headers = __assign({}, ((_a = connection.headers) !== null && _a !== void 0 ? _a : {}));
|
|
113
|
-
if (method !== "GET" && method !== "
|
|
113
|
+
if (method !== "GET" && method !== "HEAD")
|
|
114
114
|
(_b = headers["Content-Type"]) !== null && _b !== void 0 ? _b : (headers["Content-Type"] = encrypted.request === true || typeof input === "string"
|
|
115
115
|
? "text/plain"
|
|
116
116
|
: "application/json");
|
|
@@ -175,14 +175,12 @@ var Fetcher = /** @class */ (function () {
|
|
|
175
175
|
path = "/" + path;
|
|
176
176
|
url = new URL("".concat(connection.host).concat(path));
|
|
177
177
|
return [4 /*yield*/, polyfill.get()];
|
|
178
|
-
case 1: return [4 /*yield*/, (
|
|
178
|
+
case 1: return [4 /*yield*/, (_f.sent())(url.href, init)];
|
|
179
179
|
case 2:
|
|
180
|
-
response =
|
|
180
|
+
response = _f.sent();
|
|
181
181
|
return [4 /*yield*/, response.text()];
|
|
182
182
|
case 3:
|
|
183
|
-
text =
|
|
184
|
-
if (!text)
|
|
185
|
-
return [2 /*return*/, undefined];
|
|
183
|
+
text = (_d = (_f.sent())) !== null && _d !== void 0 ? _d : "";
|
|
186
184
|
// CHECK THE STATUS CODE
|
|
187
185
|
if ((encrypted.status !== undefined &&
|
|
188
186
|
response.status !== encrypted.status) ||
|
|
@@ -190,6 +188,12 @@ var Fetcher = /** @class */ (function () {
|
|
|
190
188
|
response.status !== 200 &&
|
|
191
189
|
response.status !== 201))
|
|
192
190
|
throw new HttpError_1.HttpError(method, path, response.status, text);
|
|
191
|
+
//----
|
|
192
|
+
// OUTPUT
|
|
193
|
+
//----
|
|
194
|
+
// HEAD METHOD CANNOT HAVE ANYTHING
|
|
195
|
+
if (method === "HEAD")
|
|
196
|
+
return [2 /*return*/, undefined];
|
|
193
197
|
content = !encrypted.response
|
|
194
198
|
? text
|
|
195
199
|
: (function () {
|
|
@@ -205,7 +209,7 @@ var Fetcher = /** @class */ (function () {
|
|
|
205
209
|
try {
|
|
206
210
|
// PARSE RESPONSE BODY
|
|
207
211
|
if (encrypted.response ||
|
|
208
|
-
((
|
|
212
|
+
((_e = response.headers.get("Content-Type")) !== null && _e !== void 0 ? _e : "").indexOf("application/json") !== -1)
|
|
209
213
|
ret = JSON.parse(ret);
|
|
210
214
|
// FIND __SET_HEADERS__ FIELD
|
|
211
215
|
if (ret.__set_headers__ !== undefined &&
|
|
@@ -215,7 +219,7 @@ var Fetcher = /** @class */ (function () {
|
|
|
215
219
|
Object.assign(connection.headers, ret.__set_headers__);
|
|
216
220
|
}
|
|
217
221
|
}
|
|
218
|
-
catch (
|
|
222
|
+
catch (_g) { }
|
|
219
223
|
// RETURNS
|
|
220
224
|
return [2 /*return*/, ret];
|
|
221
225
|
}
|
package/lib/Fetcher.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Fetcher.js","sourceRoot":"","sources":["../src/Fetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA8B;AAM9B,uCAAsC;AACtC,yCAAwC;AACxC,kDAAiD;AAEjD;;;;;;;;;;;;;GAaG;AACH;IAAA;
|
|
1
|
+
{"version":3,"file":"Fetcher.js","sourceRoot":"","sources":["../src/Fetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA8B;AAM9B,uCAAsC;AACtC,yCAAwC;AACxC,kDAAiD;AAEjD;;;;;;;;;;;;;GAaG;AACH;IAAA;IA+LA,CAAC;IAnJuB,aAAK,GAAzB,UACI,UAAuB,EACvB,SAA6B,EAC7B,MAA4D,EAC5D,IAAY,EACZ,KAAc,EACd,SAAqC;;;;;;;wBAErC,IAAI,SAAS,CAAC,OAAO,KAAK,IAAI,IAAI,SAAS,CAAC,QAAQ,KAAK,IAAI;4BACzD,IAAI,UAAU,CAAC,UAAU,KAAK,SAAS;gCACnC,MAAM,IAAI,KAAK,CACX,qFAAqF,CACxF,CAAC;wBAMJ,OAAO,gBAC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HttpError.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @author Jeongho Nam - https://github.com/samchon
|
|
7
7
|
*/
|
|
8
8
|
export declare class HttpError extends Error {
|
|
9
|
-
readonly method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH";
|
|
9
|
+
readonly method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH" | "HEAD";
|
|
10
10
|
readonly path: string;
|
|
11
11
|
readonly status: number;
|
|
12
12
|
/**
|
|
@@ -17,7 +17,7 @@ export declare class HttpError extends Error {
|
|
|
17
17
|
* @param status Status code from the remote HTTP server.
|
|
18
18
|
* @param message Error message from the remote HTTP server.
|
|
19
19
|
*/
|
|
20
|
-
constructor(method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH", path: string, status: number, message: string);
|
|
20
|
+
constructor(method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH" | "HEAD", path: string, status: number, message: string);
|
|
21
21
|
/**
|
|
22
22
|
* `HttpError` to JSON.
|
|
23
23
|
*
|
|
@@ -38,7 +38,7 @@ export declare namespace HttpError {
|
|
|
38
38
|
* Returned type of {@link HttpError.toJSON} method.
|
|
39
39
|
*/
|
|
40
40
|
interface IProps<T> {
|
|
41
|
-
method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH";
|
|
41
|
+
method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH" | "HEAD";
|
|
42
42
|
path: string;
|
|
43
43
|
status: number;
|
|
44
44
|
message: T;
|
package/lib/HttpError.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpError.js","sourceRoot":"","sources":["../src/HttpError.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH;IAA+B,6BAAK;IAMhC;;;;;;;OAOG;IACH,mBACoB,
|
|
1
|
+
{"version":3,"file":"HttpError.js","sourceRoot":"","sources":["../src/HttpError.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH;IAA+B,6BAAK;IAMhC;;;;;;;OAOG;IACH,mBACoB,MAMJ,EACI,IAAY,EACZ,MAAc,EAC9B,OAAe;;QAVnB,YAYI,kBAAM,OAAO,CAAC,SAMjB;QAjBmB,YAAM,GAAN,MAAM,CAMV;QACI,UAAI,GAAJ,IAAI,CAAQ;QACZ,YAAM,GAAN,MAAM,CAAQ;QAtBlC;;WAEG;QACK,WAAK,GAAQ,OAAO,CAAC;QAwBzB,uBAAuB;QACvB,IAAM,KAAK,GAAc,WAAW,SAAS,CAAC;QAC9C,IAAI,MAAM,CAAC,cAAc;YAAE,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,KAAK,CAAC,CAAC;;YACxD,KAAY,CAAC,SAAS,GAAG,KAAK,CAAC;;IACzC,CAAC;IAED;;;;;;;;;;;;OAYG;IACI,0BAAM,GAAb;QACI,IAAI,IAAI,CAAC,KAAK,KAAK,OAAO;YAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClE,OAAO;YACH,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,KAAK;SACtB,CAAC;IACN,CAAC;IACL,gBAAC;AAAD,CAAC,AAxDD,CAA+B,KAAK,GAwDnC;AAxDY,8BAAS;AAqEtB,IAAM,OAAO,GAAG,EAAS,CAAC"}
|
package/package.json
CHANGED
package/src/Fetcher.ts
CHANGED
|
@@ -23,6 +23,13 @@ import { Singleton } from "./internal/Singleton";
|
|
|
23
23
|
* @author Jeongho Nam - https://github.com/samchon
|
|
24
24
|
*/
|
|
25
25
|
export class Fetcher {
|
|
26
|
+
public static fetch(
|
|
27
|
+
connection: IConnection,
|
|
28
|
+
encrypted: Fetcher.IEncrypted,
|
|
29
|
+
method: "HEAD",
|
|
30
|
+
path: string,
|
|
31
|
+
): Promise<void>;
|
|
32
|
+
|
|
26
33
|
/**
|
|
27
34
|
* Fetch function for the `GET` methods.
|
|
28
35
|
*
|
|
@@ -62,7 +69,7 @@ export class Fetcher {
|
|
|
62
69
|
public static async fetch<Output>(
|
|
63
70
|
connection: IConnection,
|
|
64
71
|
encrypted: Fetcher.IEncrypted,
|
|
65
|
-
method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH",
|
|
72
|
+
method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH" | "HEAD",
|
|
66
73
|
path: string,
|
|
67
74
|
input?: object,
|
|
68
75
|
stringify?: (input: object) => string,
|
|
@@ -80,7 +87,7 @@ export class Fetcher {
|
|
|
80
87
|
const headers: Record<string, IConnection.HeaderValue | undefined> = {
|
|
81
88
|
...(connection.headers ?? {}),
|
|
82
89
|
};
|
|
83
|
-
if (method !== "GET" && method !== "
|
|
90
|
+
if (method !== "GET" && method !== "HEAD")
|
|
84
91
|
headers["Content-Type"] ??=
|
|
85
92
|
encrypted.request === true || typeof input === "string"
|
|
86
93
|
? "text/plain"
|
|
@@ -142,8 +149,7 @@ export class Fetcher {
|
|
|
142
149
|
|
|
143
150
|
// DO FETCH
|
|
144
151
|
const response: Response = await (await polyfill.get())(url.href, init);
|
|
145
|
-
const text: string = await response.text();
|
|
146
|
-
if (!text) return undefined!;
|
|
152
|
+
const text: string = (await response.text()) ?? "";
|
|
147
153
|
|
|
148
154
|
// CHECK THE STATUS CODE
|
|
149
155
|
if (
|
|
@@ -155,6 +161,13 @@ export class Fetcher {
|
|
|
155
161
|
)
|
|
156
162
|
throw new HttpError(method, path, response.status, text);
|
|
157
163
|
|
|
164
|
+
//----
|
|
165
|
+
// OUTPUT
|
|
166
|
+
//----
|
|
167
|
+
// HEAD METHOD CANNOT HAVE ANYTHING
|
|
168
|
+
if (method === "HEAD") return undefined!;
|
|
169
|
+
|
|
170
|
+
// DECRYPT RESPONSE BODY
|
|
158
171
|
const content: string = !encrypted.response
|
|
159
172
|
? text
|
|
160
173
|
: (() => {
|
|
@@ -174,12 +187,9 @@ export class Fetcher {
|
|
|
174
187
|
: connection.encryption!;
|
|
175
188
|
return AesPkcs5.decrypt(text, password.key, password.iv);
|
|
176
189
|
})();
|
|
177
|
-
|
|
178
|
-
//----
|
|
179
|
-
// OUTPUT
|
|
180
|
-
//----
|
|
181
190
|
let ret: { __set_headers__: Record<string, any> } & Primitive<Output> =
|
|
182
191
|
content as any;
|
|
192
|
+
|
|
183
193
|
try {
|
|
184
194
|
// PARSE RESPONSE BODY
|
|
185
195
|
if (
|
package/src/HttpError.ts
CHANGED
|
@@ -20,7 +20,13 @@ export class HttpError extends Error {
|
|
|
20
20
|
* @param message Error message from the remote HTTP server.
|
|
21
21
|
*/
|
|
22
22
|
public constructor(
|
|
23
|
-
public readonly method:
|
|
23
|
+
public readonly method:
|
|
24
|
+
| "GET"
|
|
25
|
+
| "DELETE"
|
|
26
|
+
| "POST"
|
|
27
|
+
| "PUT"
|
|
28
|
+
| "PATCH"
|
|
29
|
+
| "HEAD",
|
|
24
30
|
public readonly path: string,
|
|
25
31
|
public readonly status: number,
|
|
26
32
|
message: string,
|
|
@@ -61,7 +67,7 @@ export namespace HttpError {
|
|
|
61
67
|
* Returned type of {@link HttpError.toJSON} method.
|
|
62
68
|
*/
|
|
63
69
|
export interface IProps<T> {
|
|
64
|
-
method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH";
|
|
70
|
+
method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH" | "HEAD";
|
|
65
71
|
path: string;
|
|
66
72
|
status: number;
|
|
67
73
|
message: T;
|