@nestia/fetcher 1.3.3 → 1.3.5

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.js CHANGED
@@ -1,191 +1,188 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- var __importDefault = (this && this.__importDefault) || function (mod) {
50
- return (mod && mod.__esModule) ? mod : { "default": mod };
51
- };
52
- Object.defineProperty(exports, "__esModule", { value: true });
53
- exports.Fetcher = void 0;
54
- var import2_1 = __importDefault(require("import2"));
55
- var AesPkcs5_1 = require("./AesPkcs5");
56
- var HttpError_1 = require("./HttpError");
57
- var Singleton_1 = require("./internal/Singleton");
58
- /**
59
- * Fetcher, utility class for the [**Nestia**](https://github.com/samchon/nestia) fetch.
60
- *
61
- * `Fetcher` is a utility class providing the {@link Fetcher.fetch} functions who're being
62
- * used by all of the SDK libraries, interacting with the remote HTTP servers, who are
63
- * generated by the [**Nestia**](https://github.com/samchon/nestia).
64
- *
65
- * As this `Fetcher` be used only by the [**Nestia**](https://github.com/samchon/nestia)
66
- * generated SDK libraries, you don't need to handle this class directly. It may only be
67
- * appeared in the source codes of the [**Nestia**](https://github.com/samchon/nestia)
68
- * generated SDK libraries.
69
- *
70
- * @author Jeongho Nam - https://github.com/samchon
71
- */
72
- var Fetcher = /** @class */ (function () {
73
- function Fetcher() {
74
- }
75
- Fetcher.fetch = function (connection, encrypted, method, path, input, stringify) {
76
- var _a;
77
- return __awaiter(this, void 0, void 0, function () {
78
- var init, url, response, text, content, ret;
79
- return __generator(this, function (_b) {
80
- switch (_b.label) {
81
- case 0:
82
- if (encrypted.request === true || encrypted.response === true)
83
- if (connection.encryption === undefined)
84
- throw new Error("Error on nestia.Fetcher.encrypt(): the encryption password has not been configured.");
85
- init = {
86
- method: method,
87
- headers: encrypted.request === false &&
88
- input !== undefined &&
89
- typeof input === "object"
90
- ? __assign(__assign({}, connection.headers), { "Content-Type": "application/json" }) : (_a = connection.headers) !== null && _a !== void 0 ? _a : {},
91
- };
92
- if (encrypted.request || typeof input === "string")
93
- init.headers["Content-Type"] =
94
- "text/plain";
95
- // REQUEST BODY (WITH ENCRYPTION)
96
- if (input !== undefined)
97
- init.body = (function () {
98
- var json = (stringify !== null && stringify !== void 0 ? stringify : JSON.stringify)(input);
99
- if (!encrypted.request)
100
- return json;
101
- var password = connection.encryption instanceof Function
102
- ? connection.encryption({
103
- headers: init.headers,
104
- body: json,
105
- }, true)
106
- : connection.encryption;
107
- return AesPkcs5_1.AesPkcs5.encrypt(json, password.key, password.iv);
108
- })();
109
- //----
110
- // RESPONSE MESSAGE
111
- //----
112
- // URL SPECIFICATION
113
- if (connection.host[connection.host.length - 1] !== "/" &&
114
- path[0] !== "/")
115
- path = "/" + path;
116
- url = new URL("".concat(connection.host).concat(path));
117
- return [4 /*yield*/, polyfill.get()];
118
- case 1: return [4 /*yield*/, (_b.sent())(url.href, init)];
119
- case 2:
120
- response = _b.sent();
121
- return [4 /*yield*/, response.text()];
122
- case 3:
123
- text = _b.sent();
124
- if (!text)
125
- return [2 /*return*/, undefined];
126
- // CHECK THE STATUS CODE
127
- if ((encrypted.status !== undefined &&
128
- response.status !== encrypted.status) ||
129
- (encrypted.status === undefined &&
130
- response.status !== 200 &&
131
- response.status !== 201))
132
- throw new HttpError_1.HttpError(method, path, response.status, text);
133
- content = !encrypted.response
134
- ? text
135
- : (function () {
136
- var password = connection.encryption instanceof Function
137
- ? connection.encryption({
138
- headers: headers_to_object(response.headers),
139
- body: text,
140
- }, false)
141
- : connection.encryption;
142
- return AesPkcs5_1.AesPkcs5.decrypt(text, password.key, password.iv);
143
- })();
144
- ret = content;
145
- try {
146
- // PARSE RESPONSE BODY
147
- ret = JSON.parse(ret);
148
- // FIND __SET_HEADERS__ FIELD
149
- if (ret.__set_headers__ !== undefined &&
150
- typeof ret.__set_headers__ === "object") {
151
- if (connection.headers === undefined)
152
- connection.headers = {};
153
- Object.assign(connection.headers, ret.__set_headers__);
154
- }
155
- }
156
- catch (_c) { }
157
- // RETURNS
158
- return [2 /*return*/, ret];
159
- }
160
- });
161
- });
162
- };
163
- return Fetcher;
164
- }());
165
- exports.Fetcher = Fetcher;
166
- var polyfill = new Singleton_1.Singleton(function () { return __awaiter(void 0, void 0, void 0, function () {
167
- var _a;
168
- return __generator(this, function (_b) {
169
- switch (_b.label) {
170
- case 0:
171
- if (!(typeof global === "object" &&
172
- typeof global.process === "object" &&
173
- typeof global.process.versions === "object" &&
174
- typeof global.process.versions.node !== undefined)) return [3 /*break*/, 3];
175
- if (!(global.fetch === undefined)) return [3 /*break*/, 2];
176
- _a = global;
177
- return [4 /*yield*/, (0, import2_1.default)("node-fetch")];
178
- case 1:
179
- _a.fetch = (_b.sent()).default;
180
- _b.label = 2;
181
- case 2: return [2 /*return*/, global.fetch];
182
- case 3: return [2 /*return*/, window.fetch];
183
- }
184
- });
185
- }); });
186
- function headers_to_object(headers) {
187
- var output = {};
188
- headers.forEach(function (value, key) { return (output[key] = value); });
189
- return output;
190
- }
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
52
+ Object.defineProperty(exports, "__esModule", { value: true });
53
+ exports.Fetcher = void 0;
54
+ var import2_1 = __importDefault(require("import2"));
55
+ var AesPkcs5_1 = require("./AesPkcs5");
56
+ var HttpError_1 = require("./HttpError");
57
+ var Singleton_1 = require("./internal/Singleton");
58
+ /**
59
+ * Fetcher, utility class for the [**Nestia**](https://github.com/samchon/nestia) fetch.
60
+ *
61
+ * `Fetcher` is a utility class providing the {@link Fetcher.fetch} functions who're being
62
+ * used by all of the SDK libraries, interacting with the remote HTTP servers, who are
63
+ * generated by the [**Nestia**](https://github.com/samchon/nestia).
64
+ *
65
+ * As this `Fetcher` be used only by the [**Nestia**](https://github.com/samchon/nestia)
66
+ * generated SDK libraries, you don't need to handle this class directly. It may only be
67
+ * appeared in the source codes of the [**Nestia**](https://github.com/samchon/nestia)
68
+ * generated SDK libraries.
69
+ *
70
+ * @author Jeongho Nam - https://github.com/samchon
71
+ */
72
+ var Fetcher = /** @class */ (function () {
73
+ function Fetcher() {
74
+ }
75
+ Fetcher.fetch = function (connection, encrypted, method, path, input, stringify) {
76
+ var _a, _b;
77
+ return __awaiter(this, void 0, void 0, function () {
78
+ var init, url, response, text, content, ret;
79
+ return __generator(this, function (_c) {
80
+ switch (_c.label) {
81
+ case 0:
82
+ if (encrypted.request === true || encrypted.response === true)
83
+ if (connection.encryption === undefined)
84
+ throw new Error("Error on nestia.Fetcher.encrypt(): the encryption password has not been configured.");
85
+ init = __assign(__assign({}, ((_a = connection.options) !== null && _a !== void 0 ? _a : {})), { method: method, headers: encrypted.request === false &&
86
+ input !== undefined &&
87
+ typeof input === "object"
88
+ ? __assign(__assign({}, connection.headers), { "Content-Type": "application/json" }) : (_b = connection.headers) !== null && _b !== void 0 ? _b : {} });
89
+ if (encrypted.request || typeof input === "string")
90
+ init.headers["Content-Type"] =
91
+ "text/plain";
92
+ // REQUEST BODY (WITH ENCRYPTION)
93
+ if (input !== undefined)
94
+ init.body = (function () {
95
+ var json = (stringify !== null && stringify !== void 0 ? stringify : JSON.stringify)(input);
96
+ if (!encrypted.request)
97
+ return json;
98
+ var password = connection.encryption instanceof Function
99
+ ? connection.encryption({
100
+ headers: init.headers,
101
+ body: json,
102
+ }, true)
103
+ : connection.encryption;
104
+ return AesPkcs5_1.AesPkcs5.encrypt(json, password.key, password.iv);
105
+ })();
106
+ //----
107
+ // RESPONSE MESSAGE
108
+ //----
109
+ // URL SPECIFICATION
110
+ if (connection.host[connection.host.length - 1] !== "/" &&
111
+ path[0] !== "/")
112
+ path = "/" + path;
113
+ url = new URL("".concat(connection.host).concat(path));
114
+ return [4 /*yield*/, polyfill.get()];
115
+ case 1: return [4 /*yield*/, (_c.sent())(url.href, init)];
116
+ case 2:
117
+ response = _c.sent();
118
+ return [4 /*yield*/, response.text()];
119
+ case 3:
120
+ text = _c.sent();
121
+ if (!text)
122
+ return [2 /*return*/, undefined];
123
+ // CHECK THE STATUS CODE
124
+ if ((encrypted.status !== undefined &&
125
+ response.status !== encrypted.status) ||
126
+ (encrypted.status === undefined &&
127
+ response.status !== 200 &&
128
+ response.status !== 201))
129
+ throw new HttpError_1.HttpError(method, path, response.status, text);
130
+ content = !encrypted.response
131
+ ? text
132
+ : (function () {
133
+ var password = connection.encryption instanceof Function
134
+ ? connection.encryption({
135
+ headers: headers_to_object(response.headers),
136
+ body: text,
137
+ }, false)
138
+ : connection.encryption;
139
+ return AesPkcs5_1.AesPkcs5.decrypt(text, password.key, password.iv);
140
+ })();
141
+ ret = content;
142
+ try {
143
+ // PARSE RESPONSE BODY
144
+ ret = JSON.parse(ret);
145
+ // FIND __SET_HEADERS__ FIELD
146
+ if (ret.__set_headers__ !== undefined &&
147
+ typeof ret.__set_headers__ === "object") {
148
+ if (connection.headers === undefined)
149
+ connection.headers = {};
150
+ Object.assign(connection.headers, ret.__set_headers__);
151
+ }
152
+ }
153
+ catch (_d) { }
154
+ // RETURNS
155
+ return [2 /*return*/, ret];
156
+ }
157
+ });
158
+ });
159
+ };
160
+ return Fetcher;
161
+ }());
162
+ exports.Fetcher = Fetcher;
163
+ var polyfill = new Singleton_1.Singleton(function () { return __awaiter(void 0, void 0, void 0, function () {
164
+ var _a;
165
+ return __generator(this, function (_b) {
166
+ switch (_b.label) {
167
+ case 0:
168
+ if (!(typeof global === "object" &&
169
+ typeof global.process === "object" &&
170
+ typeof global.process.versions === "object" &&
171
+ typeof global.process.versions.node !== undefined)) return [3 /*break*/, 3];
172
+ if (!(global.fetch === undefined)) return [3 /*break*/, 2];
173
+ _a = global;
174
+ return [4 /*yield*/, (0, import2_1.default)("node-fetch")];
175
+ case 1:
176
+ _a.fetch = (_b.sent()).default;
177
+ _b.label = 2;
178
+ case 2: return [2 /*return*/, global.fetch];
179
+ case 3: return [2 /*return*/, window.fetch];
180
+ }
181
+ });
182
+ }); });
183
+ function headers_to_object(headers) {
184
+ var output = {};
185
+ headers.forEach(function (value, key) { return (output[key] = value); });
186
+ return output;
187
+ }
191
188
  //# sourceMappingURL=Fetcher.js.map
@@ -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;IAoKA,CAAC;IA/HuB,aAAK,GAAzB,UACI,UAAuB,EACvB,SAA6B,EAC7B,MAAmD,EACnD,IAAY,EACZ,KAAc,EACd,SAAqC;;;;;;;wBAErC,IAAI,SAAS,CAAC,OAAO,KAAK,IAAI,IAAI,SAAS,CAAC,QAAQ,KAAK,IAAI;4BACzD,IAAI,UAAU,C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AC;6BAC1D;yBACJ;wBAAC,WAAM,GAAE;wBAEV,UAAU;wBACV,sBAAO,GAAG,EAAC;;;;KACd;IACL,cAAC;AAAD,CAAC,AArKD,IAqKC;AArKY,0BAAO;AA0MpB,IAAM,QAAQ,GAAG,IAAI,qBAAS,CAAC;;;;;qBAEvB,CAAA,OAAO,MAAM,KAAK,QAAQ;oBAC1B,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ;oBAClC,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ;oBAC3C,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAA,EAHjD,wBAGiD;qBAE7C,CAAA,MAAM,CAAC,KAAK,KAAK,SAAS,CAAA,EAA1B,wBAA0B;gBAC1B,KAAA,MAAM,CAAA;gBAAW,qBAAM,IAAA,iBAAO,EAAC,YAAY,CAAC,EAAA;;gBAA5C,GAAO,KAAK,GAAI,CAAC,SAA2B,CAAS,CAAC,OAAO,CAAC;;oBAClE,sBAAQ,MAAc,CAAC,KAAK,EAAC;oBAEjC,sBAAO,MAAM,CAAC,KAAK,EAAC;;;KACvB,CAAC,CAAC;AAEH,SAAS,iBAAiB,CAAC,OAAgB;IACvC,IAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,OAAO,CAAC,OAAO,CAAC,UAAC,KAAK,EAAE,GAAG,IAAK,OAAA,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,EAArB,CAAqB,CAAC,CAAC;IACvD,OAAO,MAAM,CAAC;AAClB,CAAC"}
@@ -1,46 +1,46 @@
1
- /**
2
- * HTTP Error.
3
- *
4
- * `HttpError` is a type of error class who've been thrown by the remote HTTP server.
5
- *
6
- * @author Jeongho Nam - https://github.com/samchon
7
- */
8
- export declare class HttpError extends Error {
9
- readonly method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH";
10
- readonly path: string;
11
- readonly status: number;
12
- /**
13
- * Initializer Constructor.
14
- *
15
- * @param method Method of the HTTP request.
16
- * @param path Path of the HTTP request.
17
- * @param status Status code from the remote HTTP server.
18
- * @param message Error message from the remote HTTP server.
19
- */
20
- constructor(method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH", path: string, status: number, message: string);
21
- /**
22
- * `HttpError` to JSON.
23
- *
24
- * When you call `JSON.stringify()` function on current `HttpError` instance,
25
- * this `HttpError.toJSON()` method would be automatically called.
26
- *
27
- * Also, if response body from the remote HTTP server forms a JSON object,
28
- * this `HttpError.toJSON()` method would be useful because it returns the
29
- * parsed JSON object about the {@link message} property.
30
- *
31
- * @template T Expected type of the response body.
32
- * @returns JSON object of the `HttpError`.
33
- */
34
- toJSON<T>(): HttpError.IProps<T>;
35
- }
36
- export declare namespace HttpError {
37
- /**
38
- * Returned type of {@link HttpError.toJSON} method.
39
- */
40
- interface IProps<T> {
41
- method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH";
42
- path: string;
43
- status: number;
44
- message: T;
45
- }
46
- }
1
+ /**
2
+ * HTTP Error.
3
+ *
4
+ * `HttpError` is a type of error class who've been thrown by the remote HTTP server.
5
+ *
6
+ * @author Jeongho Nam - https://github.com/samchon
7
+ */
8
+ export declare class HttpError extends Error {
9
+ readonly method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH";
10
+ readonly path: string;
11
+ readonly status: number;
12
+ /**
13
+ * Initializer Constructor.
14
+ *
15
+ * @param method Method of the HTTP request.
16
+ * @param path Path of the HTTP request.
17
+ * @param status Status code from the remote HTTP server.
18
+ * @param message Error message from the remote HTTP server.
19
+ */
20
+ constructor(method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH", path: string, status: number, message: string);
21
+ /**
22
+ * `HttpError` to JSON.
23
+ *
24
+ * When you call `JSON.stringify()` function on current `HttpError` instance,
25
+ * this `HttpError.toJSON()` method would be automatically called.
26
+ *
27
+ * Also, if response body from the remote HTTP server forms a JSON object,
28
+ * this `HttpError.toJSON()` method would be useful because it returns the
29
+ * parsed JSON object about the {@link message} property.
30
+ *
31
+ * @template T Expected type of the response body.
32
+ * @returns JSON object of the `HttpError`.
33
+ */
34
+ toJSON<T>(): HttpError.IProps<T>;
35
+ }
36
+ export declare namespace HttpError {
37
+ /**
38
+ * Returned type of {@link HttpError.toJSON} method.
39
+ */
40
+ interface IProps<T> {
41
+ method: "GET" | "DELETE" | "POST" | "PUT" | "PATCH";
42
+ path: string;
43
+ status: number;
44
+ message: T;
45
+ }
46
+ }