@arkyn/server 3.0.1-beta.159 → 3.0.1-beta.166
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/index.js +1026 -1262
- package/dist/modules/http/api/_logRequest.js +55 -68
- package/dist/modules/http/api/_makeRequest.js +69 -68
- package/dist/modules/http/api/deleteRequest.js +12 -12
- package/dist/modules/http/api/getRequest.js +11 -11
- package/dist/modules/http/api/patchRequest.js +11 -11
- package/dist/modules/http/api/postRequest.js +11 -11
- package/dist/modules/http/api/putRequest.js +11 -11
- package/dist/modules/http/badResponses/_badResponse.js +62 -58
- package/dist/modules/http/badResponses/badGateway.js +22 -28
- package/dist/modules/http/badResponses/badRequest.js +22 -28
- package/dist/modules/http/badResponses/conflict.js +22 -28
- package/dist/modules/http/badResponses/forbidden.js +22 -28
- package/dist/modules/http/badResponses/notFound.js +22 -28
- package/dist/modules/http/badResponses/notImplemented.js +22 -28
- package/dist/modules/http/badResponses/serverError.js +22 -28
- package/dist/modules/http/badResponses/unauthorized.js +22 -28
- package/dist/modules/http/badResponses/unprocessableEntity.js +27 -35
- package/dist/modules/http/successResponses/_successResponse.js +61 -68
- package/dist/modules/http/successResponses/created.js +22 -28
- package/dist/modules/http/successResponses/found.js +22 -28
- package/dist/modules/http/successResponses/noContent.js +16 -20
- package/dist/modules/http/successResponses/success.js +22 -28
- package/dist/modules/http/successResponses/updated.js +22 -28
- package/dist/modules/index.js +33 -67
- package/dist/modules/services/apiService.js +108 -128
- package/dist/modules/services/debugService.js +35 -65
- package/dist/modules/services/logMapperService.js +28 -51
- package/dist/modules/services/logService.js +20 -30
- package/dist/modules/utilities/decodeRequestBody.js +19 -21
- package/dist/modules/utilities/decodeRequestErrorMessage.js +5 -6
- package/dist/modules/utilities/errorHandler.js +36 -51
- package/dist/modules/utilities/flushDebugLogs.js +15 -19
- package/dist/modules/utilities/formAsyncParse.js +13 -18
- package/dist/modules/utilities/formParse.js +13 -18
- package/dist/modules/utilities/getScopedParams.js +8 -10
- package/dist/modules/utilities/schemaValidator.js +53 -104
- package/dist/modules/validations/validateCep.js +8 -8
- package/dist/modules/validations/validateCnpj.js +49 -26
- package/dist/modules/validations/validateCpf.js +22 -23
- package/dist/modules/validations/validateDate.js +25 -26
- package/dist/modules/validations/validateEmail.js +54 -53
- package/dist/modules/validations/validatePassword.js +11 -15
- package/dist/modules/validations/validatePhone.js +8 -8
- package/dist/modules/validations/validateRg.js +7 -7
- package/generate-version.ts +74 -0
- package/package.json +17 -9
|
@@ -1,69 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LogService as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
`Status text: ${q}.`,
|
|
55
|
-
`JSON Response: ${s ? w(s, 0) : "No JSON response"}`
|
|
56
|
-
]
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
} catch (e) {
|
|
60
|
-
n({
|
|
61
|
-
debugs: [`Error sending request: ${e}`],
|
|
62
|
-
name: "LogError",
|
|
63
|
-
scheme: "red"
|
|
64
|
-
});
|
|
65
|
-
}
|
|
1
|
+
import { flushDebugLogs as e } from "../../utilities/flushDebugLogs.js";
|
|
2
|
+
import { LogService as t } from "../../services/logService.js";
|
|
3
|
+
import { formatJsonObject as n } from "@arkyn/shared";
|
|
4
|
+
//#region src/http/api/_logRequest.ts
|
|
5
|
+
async function r(r) {
|
|
6
|
+
let i = t.getConfig();
|
|
7
|
+
if (!i) return;
|
|
8
|
+
let { userToken: a, apiUrl: o, trafficSourceId: s } = i, { elapsedTime: c, method: l, queryParams: u, requestBody: d, requestHeaders: f, responseBody: p, responseHeaders: m, status: h, token: g, rawUrl: _ } = r;
|
|
9
|
+
if (process.env.NODE_ENV !== "development") try {
|
|
10
|
+
let t = new URL(_), r = "https";
|
|
11
|
+
t.protocol === "http:" && (r = "http");
|
|
12
|
+
let i = JSON.stringify({
|
|
13
|
+
domainUrl: t.protocol + "//" + t.host,
|
|
14
|
+
pathnameUrl: t.pathname,
|
|
15
|
+
trafficSourceId: s,
|
|
16
|
+
status: h,
|
|
17
|
+
protocol: r,
|
|
18
|
+
method: l.toLowerCase(),
|
|
19
|
+
trafficUserId: null,
|
|
20
|
+
elapsedTime: c,
|
|
21
|
+
requestHeaders: JSON.stringify(f),
|
|
22
|
+
requestBody: JSON.stringify(d),
|
|
23
|
+
queryParams: JSON.stringify(u),
|
|
24
|
+
responseHeaders: JSON.stringify(m),
|
|
25
|
+
responseBody: JSON.stringify(p)
|
|
26
|
+
}), g = {
|
|
27
|
+
"Content-Type": "application/json",
|
|
28
|
+
Authorization: `Bearer ${a}`
|
|
29
|
+
}, v = await fetch(o, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
body: i,
|
|
32
|
+
headers: g
|
|
33
|
+
});
|
|
34
|
+
if (!v.ok) {
|
|
35
|
+
let t = await v.text(), r = v.status, i = v.statusText, a = await v.json().catch(() => null);
|
|
36
|
+
e({
|
|
37
|
+
name: "LogError",
|
|
38
|
+
scheme: "red",
|
|
39
|
+
debugs: [
|
|
40
|
+
"Failed to log request.",
|
|
41
|
+
`Status: ${r} ${i}.`,
|
|
42
|
+
`Status text: ${t}.`,
|
|
43
|
+
`JSON Response: ${a ? n(a, 0) : "No JSON response"}`
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
} catch (t) {
|
|
48
|
+
e({
|
|
49
|
+
debugs: [`Error sending request: ${t}`],
|
|
50
|
+
name: "LogError",
|
|
51
|
+
scheme: "red"
|
|
52
|
+
});
|
|
53
|
+
}
|
|
66
54
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
};
|
|
55
|
+
//#endregion
|
|
56
|
+
export { r as logRequest };
|
|
@@ -1,69 +1,70 @@
|
|
|
1
|
-
import { flushDebugLogs as
|
|
2
|
-
import { LogMapperService as
|
|
3
|
-
import { logRequest as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
1
|
+
import { flushDebugLogs as e } from "../../utilities/flushDebugLogs.js";
|
|
2
|
+
import { LogMapperService as t } from "../../services/logMapperService.js";
|
|
3
|
+
import { logRequest as n } from "./_logRequest.js";
|
|
4
|
+
//#region src/http/api/_makeRequest.ts
|
|
5
|
+
async function r(r) {
|
|
6
|
+
let i = r.url;
|
|
7
|
+
r.urlParams && Object.entries(r.urlParams).forEach(([e, t]) => {
|
|
8
|
+
i = i.replaceAll(`:${e}`, t);
|
|
9
|
+
});
|
|
10
|
+
let a = {
|
|
11
|
+
POST: "Resource created successfully",
|
|
12
|
+
PUT: "Resource updated successfully",
|
|
13
|
+
DELETE: "Resource deleted successfully",
|
|
14
|
+
PATCH: "Resource patched successfully",
|
|
15
|
+
GET: "Request successful"
|
|
16
|
+
};
|
|
17
|
+
try {
|
|
18
|
+
let e = performance.now(), o = {
|
|
19
|
+
...r.headers,
|
|
20
|
+
"Content-Type": "application/json"
|
|
21
|
+
}, s = await fetch(i, {
|
|
22
|
+
headers: o,
|
|
23
|
+
method: r.method,
|
|
24
|
+
body: r.body ? JSON.stringify(r.body) : void 0
|
|
25
|
+
}), c = performance.now() - e, l = s.status, u = null;
|
|
26
|
+
try {
|
|
27
|
+
u = await s.json();
|
|
28
|
+
} catch {
|
|
29
|
+
u = null;
|
|
30
|
+
}
|
|
31
|
+
return n(t.handle({
|
|
32
|
+
elapsedTime: c,
|
|
33
|
+
method: r.method,
|
|
34
|
+
queryParams: new URL(i).searchParams,
|
|
35
|
+
requestHeaders: o,
|
|
36
|
+
requestBody: r.body,
|
|
37
|
+
responseBody: u,
|
|
38
|
+
responseHeaders: s.headers,
|
|
39
|
+
status: l,
|
|
40
|
+
rawUrl: r.url,
|
|
41
|
+
urlParams: r.urlParams
|
|
42
|
+
})), s.ok ? {
|
|
43
|
+
success: !0,
|
|
44
|
+
status: l,
|
|
45
|
+
message: u?.message || a[r.method],
|
|
46
|
+
response: u,
|
|
47
|
+
cause: null
|
|
48
|
+
} : {
|
|
49
|
+
success: !1,
|
|
50
|
+
status: l,
|
|
51
|
+
message: u?.message || s.statusText || "Request failed",
|
|
52
|
+
response: u,
|
|
53
|
+
cause: null
|
|
54
|
+
};
|
|
55
|
+
} catch (t) {
|
|
56
|
+
return e({
|
|
57
|
+
debugs: [`Network error or request failed: ${t}`],
|
|
58
|
+
name: "MakeRequestError",
|
|
59
|
+
scheme: "red"
|
|
60
|
+
}), {
|
|
61
|
+
success: !1,
|
|
62
|
+
status: 0,
|
|
63
|
+
message: "Network error or request failed",
|
|
64
|
+
response: null,
|
|
65
|
+
cause: t instanceof Error ? t.message : String(t)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
66
68
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
};
|
|
69
|
+
//#endregion
|
|
70
|
+
export { r as makeRequest };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { makeRequest as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { makeRequest as e } from "./_makeRequest.js";
|
|
2
|
+
//#region src/http/api/deleteRequest.ts
|
|
3
|
+
async function t(t) {
|
|
4
|
+
return e({
|
|
5
|
+
method: "DELETE",
|
|
6
|
+
url: t.url,
|
|
7
|
+
urlParams: t.urlParams,
|
|
8
|
+
headers: t.headers,
|
|
9
|
+
body: t.body
|
|
10
|
+
});
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { t as deleteRequest };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { makeRequest as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { makeRequest as e } from "./_makeRequest.js";
|
|
2
|
+
//#region src/http/api/getRequest.ts
|
|
3
|
+
async function t(t) {
|
|
4
|
+
return e({
|
|
5
|
+
method: "GET",
|
|
6
|
+
url: t.url,
|
|
7
|
+
urlParams: t.urlParams,
|
|
8
|
+
headers: t.headers
|
|
9
|
+
});
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as getRequest };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { makeRequest as e } from "./_makeRequest.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
//#region src/http/api/patchRequest.ts
|
|
3
|
+
async function t(t) {
|
|
4
|
+
return e({
|
|
5
|
+
method: "PATCH",
|
|
6
|
+
url: t.url,
|
|
7
|
+
urlParams: t.urlParams,
|
|
8
|
+
headers: t.headers,
|
|
9
|
+
body: t.body
|
|
10
|
+
});
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { t as patchRequest };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { makeRequest as e } from "./_makeRequest.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
//#region src/http/api/postRequest.ts
|
|
3
|
+
async function t(t) {
|
|
4
|
+
return e({
|
|
5
|
+
method: "POST",
|
|
6
|
+
url: t.url,
|
|
7
|
+
urlParams: t.urlParams,
|
|
8
|
+
headers: t.headers,
|
|
9
|
+
body: t.body
|
|
10
|
+
});
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { t as postRequest };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { makeRequest as e } from "./_makeRequest.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
//#region src/http/api/putRequest.ts
|
|
3
|
+
async function t(t) {
|
|
4
|
+
return e({
|
|
5
|
+
method: "PUT",
|
|
6
|
+
url: t.url,
|
|
7
|
+
urlParams: t.urlParams,
|
|
8
|
+
headers: t.headers,
|
|
9
|
+
body: t.body
|
|
10
|
+
});
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { t as putRequest };
|
|
@@ -1,59 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
1
|
+
import { DebugService as e } from "../../services/debugService.js";
|
|
2
|
+
import { flushDebugLogs as t } from "../../utilities/flushDebugLogs.js";
|
|
3
|
+
import { formatJsonString as n } from "@arkyn/shared";
|
|
4
|
+
//#region src/http/badResponses/_badResponse.ts
|
|
5
|
+
var r = class {
|
|
6
|
+
_cause;
|
|
7
|
+
_name = "BadResponse";
|
|
8
|
+
_status = 500;
|
|
9
|
+
_statusText = "Unknown error";
|
|
10
|
+
_debugColor = "red";
|
|
11
|
+
get cause() {
|
|
12
|
+
return this._cause;
|
|
13
|
+
}
|
|
14
|
+
set cause(e) {
|
|
15
|
+
this._cause = e;
|
|
16
|
+
}
|
|
17
|
+
get name() {
|
|
18
|
+
return this._name;
|
|
19
|
+
}
|
|
20
|
+
set name(e) {
|
|
21
|
+
this._name = e;
|
|
22
|
+
}
|
|
23
|
+
get status() {
|
|
24
|
+
return this._status;
|
|
25
|
+
}
|
|
26
|
+
set status(e) {
|
|
27
|
+
this._status = e;
|
|
28
|
+
}
|
|
29
|
+
get statusText() {
|
|
30
|
+
return this._statusText;
|
|
31
|
+
}
|
|
32
|
+
set statusText(e) {
|
|
33
|
+
this._statusText = e;
|
|
34
|
+
}
|
|
35
|
+
get debugColor() {
|
|
36
|
+
return this._debugColor;
|
|
37
|
+
}
|
|
38
|
+
set debugColor(e) {
|
|
39
|
+
[
|
|
40
|
+
"green",
|
|
41
|
+
"yellow",
|
|
42
|
+
"cyan",
|
|
43
|
+
"red"
|
|
44
|
+
].includes(e) && (this._debugColor = e);
|
|
45
|
+
}
|
|
46
|
+
onDebug() {
|
|
47
|
+
let r = [], { callerInfo: i, functionName: a } = e.getCaller();
|
|
48
|
+
r.push(`Caller Function: ${a}`), r.push(`Caller Location: ${i}`), this._statusText && r.push(`Message: ${this._statusText}`), this._cause && r.push(`Cause: ${n(JSON.stringify(this._cause))}`), t({
|
|
49
|
+
scheme: "red",
|
|
50
|
+
name: this._name,
|
|
51
|
+
debugs: r
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
makeBody() {
|
|
55
|
+
return {
|
|
56
|
+
name: this._name,
|
|
57
|
+
message: this._statusText,
|
|
58
|
+
cause: this._cause
|
|
59
|
+
};
|
|
60
|
+
}
|
|
59
61
|
};
|
|
62
|
+
//#endregion
|
|
63
|
+
export { r as BadResponse };
|
|
@@ -1,30 +1,24 @@
|
|
|
1
1
|
import { BadResponse as e } from "./_badResponse.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
status: this.status,
|
|
23
|
-
statusText: this.statusText
|
|
24
|
-
};
|
|
25
|
-
return Response.json(this.makeBody(), s);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export {
|
|
29
|
-
o as BadGateway
|
|
2
|
+
//#region src/http/badResponses/badGateway.ts
|
|
3
|
+
var t = class extends e {
|
|
4
|
+
constructor(e, t) {
|
|
5
|
+
super(), this.name = "BadGateway", this.status = 502, this.statusText = e, this.cause = t ? JSON.stringify(t) : void 0, this.onDebug();
|
|
6
|
+
}
|
|
7
|
+
toResponse() {
|
|
8
|
+
let e = {
|
|
9
|
+
headers: { "Content-Type": "application/json" },
|
|
10
|
+
status: this.status,
|
|
11
|
+
statusText: this.statusText
|
|
12
|
+
};
|
|
13
|
+
return new Response(JSON.stringify(this.makeBody()), e);
|
|
14
|
+
}
|
|
15
|
+
toJson() {
|
|
16
|
+
let e = {
|
|
17
|
+
status: this.status,
|
|
18
|
+
statusText: this.statusText
|
|
19
|
+
};
|
|
20
|
+
return Response.json(this.makeBody(), e);
|
|
21
|
+
}
|
|
30
22
|
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { t as BadGateway };
|
|
@@ -1,30 +1,24 @@
|
|
|
1
1
|
import { BadResponse as e } from "./_badResponse.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
status: this.status,
|
|
23
|
-
statusText: this.statusText
|
|
24
|
-
};
|
|
25
|
-
return Response.json(this.makeBody(), s);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export {
|
|
29
|
-
i as BadRequest
|
|
2
|
+
//#region src/http/badResponses/badRequest.ts
|
|
3
|
+
var t = class extends e {
|
|
4
|
+
constructor(e, t) {
|
|
5
|
+
super(), this.name = "BadRequest", this.status = 400, this.statusText = e, this.cause = t ? JSON.stringify(t) : void 0, this.onDebug();
|
|
6
|
+
}
|
|
7
|
+
toResponse() {
|
|
8
|
+
let e = {
|
|
9
|
+
headers: { "Content-Type": "application/json" },
|
|
10
|
+
status: this.status,
|
|
11
|
+
statusText: this.statusText
|
|
12
|
+
};
|
|
13
|
+
return new Response(JSON.stringify(this.makeBody()), e);
|
|
14
|
+
}
|
|
15
|
+
toJson() {
|
|
16
|
+
let e = {
|
|
17
|
+
status: this.status,
|
|
18
|
+
statusText: this.statusText
|
|
19
|
+
};
|
|
20
|
+
return Response.json(this.makeBody(), e);
|
|
21
|
+
}
|
|
30
22
|
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { t as BadRequest };
|