@arkyn/server 3.0.1-beta.166 → 3.0.1-beta.170
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/package.json +4 -3
- package/dist/http/api/_logRequest.d.ts +0 -58
- package/dist/http/api/_logRequest.d.ts.map +0 -1
- package/dist/http/api/_makeRequest.d.ts +0 -61
- package/dist/http/api/_makeRequest.d.ts.map +0 -1
- package/dist/http/api/deleteRequest.d.ts +0 -17
- package/dist/http/api/deleteRequest.d.ts.map +0 -1
- package/dist/http/api/getRequest.d.ts +0 -16
- package/dist/http/api/getRequest.d.ts.map +0 -1
- package/dist/http/api/patchRequest.d.ts +0 -17
- package/dist/http/api/patchRequest.d.ts.map +0 -1
- package/dist/http/api/postRequest.d.ts +0 -17
- package/dist/http/api/postRequest.d.ts.map +0 -1
- package/dist/http/api/putRequest.d.ts +0 -17
- package/dist/http/api/putRequest.d.ts.map +0 -1
- package/dist/http/badResponses/_badResponse.d.ts +0 -25
- package/dist/http/badResponses/_badResponse.d.ts.map +0 -1
- package/dist/http/badResponses/badGateway.d.ts +0 -24
- package/dist/http/badResponses/badGateway.d.ts.map +0 -1
- package/dist/http/badResponses/badRequest.d.ts +0 -22
- package/dist/http/badResponses/badRequest.d.ts.map +0 -1
- package/dist/http/badResponses/conflict.d.ts +0 -22
- package/dist/http/badResponses/conflict.d.ts.map +0 -1
- package/dist/http/badResponses/forbidden.d.ts +0 -22
- package/dist/http/badResponses/forbidden.d.ts.map +0 -1
- package/dist/http/badResponses/notFound.d.ts +0 -22
- package/dist/http/badResponses/notFound.d.ts.map +0 -1
- package/dist/http/badResponses/notImplemented.d.ts +0 -22
- package/dist/http/badResponses/notImplemented.d.ts.map +0 -1
- package/dist/http/badResponses/serverError.d.ts +0 -22
- package/dist/http/badResponses/serverError.d.ts.map +0 -1
- package/dist/http/badResponses/unauthorized.d.ts +0 -22
- package/dist/http/badResponses/unauthorized.d.ts.map +0 -1
- package/dist/http/badResponses/unprocessableEntity.d.ts +0 -34
- package/dist/http/badResponses/unprocessableEntity.d.ts.map +0 -1
- package/dist/http/successResponses/_successResponse.d.ts +0 -36
- package/dist/http/successResponses/_successResponse.d.ts.map +0 -1
- package/dist/http/successResponses/created.d.ts +0 -22
- package/dist/http/successResponses/created.d.ts.map +0 -1
- package/dist/http/successResponses/found.d.ts +0 -22
- package/dist/http/successResponses/found.d.ts.map +0 -1
- package/dist/http/successResponses/noContent.d.ts +0 -20
- package/dist/http/successResponses/noContent.d.ts.map +0 -1
- package/dist/http/successResponses/success.d.ts +0 -22
- package/dist/http/successResponses/success.d.ts.map +0 -1
- package/dist/http/successResponses/updated.d.ts +0 -23
- package/dist/http/successResponses/updated.d.ts.map +0 -1
- package/dist/index.d.ts +0 -34
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -1065
- package/dist/modules/http/api/_logRequest.js +0 -56
- package/dist/modules/http/api/_makeRequest.js +0 -70
- package/dist/modules/http/api/deleteRequest.js +0 -13
- package/dist/modules/http/api/getRequest.js +0 -12
- package/dist/modules/http/api/patchRequest.js +0 -13
- package/dist/modules/http/api/postRequest.js +0 -13
- package/dist/modules/http/api/putRequest.js +0 -13
- package/dist/modules/http/badResponses/_badResponse.js +0 -63
- package/dist/modules/http/badResponses/badGateway.js +0 -24
- package/dist/modules/http/badResponses/badRequest.js +0 -24
- package/dist/modules/http/badResponses/conflict.js +0 -24
- package/dist/modules/http/badResponses/forbidden.js +0 -24
- package/dist/modules/http/badResponses/notFound.js +0 -24
- package/dist/modules/http/badResponses/notImplemented.js +0 -24
- package/dist/modules/http/badResponses/serverError.js +0 -24
- package/dist/modules/http/badResponses/unauthorized.js +0 -24
- package/dist/modules/http/badResponses/unprocessableEntity.js +0 -28
- package/dist/modules/http/successResponses/_successResponse.js +0 -62
- package/dist/modules/http/successResponses/created.js +0 -24
- package/dist/modules/http/successResponses/found.js +0 -24
- package/dist/modules/http/successResponses/noContent.js +0 -17
- package/dist/modules/http/successResponses/success.js +0 -24
- package/dist/modules/http/successResponses/updated.js +0 -24
- package/dist/modules/index.js +0 -34
- package/dist/modules/services/apiService.js +0 -109
- package/dist/modules/services/debugService.js +0 -36
- package/dist/modules/services/logMapperService.js +0 -29
- package/dist/modules/services/logService.js +0 -21
- package/dist/modules/utilities/decodeRequestBody.js +0 -20
- package/dist/modules/utilities/decodeRequestErrorMessage.js +0 -6
- package/dist/modules/utilities/errorHandler.js +0 -39
- package/dist/modules/utilities/flushDebugLogs.js +0 -16
- package/dist/modules/utilities/formAsyncParse.js +0 -14
- package/dist/modules/utilities/formParse.js +0 -14
- package/dist/modules/utilities/getScopedParams.js +0 -9
- package/dist/modules/utilities/schemaValidator.js +0 -55
- package/dist/modules/validations/validateCep.js +0 -9
- package/dist/modules/validations/validateCnpj.js +0 -54
- package/dist/modules/validations/validateCpf.js +0 -27
- package/dist/modules/validations/validateDate.js +0 -26
- package/dist/modules/validations/validateEmail.js +0 -54
- package/dist/modules/validations/validatePassword.js +0 -12
- package/dist/modules/validations/validatePhone.js +0 -10
- package/dist/modules/validations/validateRg.js +0 -8
- package/dist/services/apiService.d.ts +0 -83
- package/dist/services/apiService.d.ts.map +0 -1
- package/dist/services/debugService.d.ts +0 -37
- package/dist/services/debugService.d.ts.map +0 -1
- package/dist/services/logMapperService.d.ts +0 -86
- package/dist/services/logMapperService.d.ts.map +0 -1
- package/dist/services/logService.d.ts +0 -33
- package/dist/services/logService.d.ts.map +0 -1
- package/dist/utilities/decodeRequestBody.d.ts +0 -18
- package/dist/utilities/decodeRequestBody.d.ts.map +0 -1
- package/dist/utilities/decodeRequestErrorMessage.d.ts +0 -19
- package/dist/utilities/decodeRequestErrorMessage.d.ts.map +0 -1
- package/dist/utilities/errorHandler.d.ts +0 -25
- package/dist/utilities/errorHandler.d.ts.map +0 -1
- package/dist/utilities/flushDebugLogs.d.ts +0 -24
- package/dist/utilities/flushDebugLogs.d.ts.map +0 -1
- package/dist/utilities/formAsyncParse.d.ts +0 -38
- package/dist/utilities/formAsyncParse.d.ts.map +0 -1
- package/dist/utilities/formParse.d.ts +0 -38
- package/dist/utilities/formParse.d.ts.map +0 -1
- package/dist/utilities/getScopedParams.d.ts +0 -19
- package/dist/utilities/getScopedParams.d.ts.map +0 -1
- package/dist/utilities/schemaValidator.d.ts +0 -75
- package/dist/utilities/schemaValidator.d.ts.map +0 -1
- package/dist/validations/validateCep.d.ts +0 -19
- package/dist/validations/validateCep.d.ts.map +0 -1
- package/dist/validations/validateCnpj.d.ts +0 -21
- package/dist/validations/validateCnpj.d.ts.map +0 -1
- package/dist/validations/validateCpf.d.ts +0 -16
- package/dist/validations/validateCpf.d.ts.map +0 -1
- package/dist/validations/validateDate.d.ts +0 -23
- package/dist/validations/validateDate.d.ts.map +0 -1
- package/dist/validations/validateEmail.d.ts +0 -21
- package/dist/validations/validateEmail.d.ts.map +0 -1
- package/dist/validations/validatePassword.d.ts +0 -20
- package/dist/validations/validatePassword.d.ts.map +0 -1
- package/dist/validations/validatePhone.d.ts +0 -16
- package/dist/validations/validatePhone.d.ts.map +0 -1
- package/dist/validations/validateRg.d.ts +0 -21
- package/dist/validations/validateRg.d.ts.map +0 -1
- package/generate-version.ts +0 -74
|
@@ -1,56 +0,0 @@
|
|
|
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
|
-
}
|
|
54
|
-
}
|
|
55
|
-
//#endregion
|
|
56
|
-
export { r as logRequest };
|
|
@@ -1,70 +0,0 @@
|
|
|
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
|
-
}
|
|
68
|
-
}
|
|
69
|
-
//#endregion
|
|
70
|
-
export { r as makeRequest };
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
});
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
export { t as deleteRequest };
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
});
|
|
10
|
-
}
|
|
11
|
-
//#endregion
|
|
12
|
-
export { t as getRequest };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { makeRequest as e } from "./_makeRequest.js";
|
|
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
|
-
});
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
export { t as patchRequest };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { makeRequest as e } from "./_makeRequest.js";
|
|
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
|
-
});
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
export { t as postRequest };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { makeRequest as e } from "./_makeRequest.js";
|
|
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
|
-
});
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
export { t as putRequest };
|
|
@@ -1,63 +0,0 @@
|
|
|
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
|
-
}
|
|
61
|
-
};
|
|
62
|
-
//#endregion
|
|
63
|
-
export { r as BadResponse };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { BadResponse as e } from "./_badResponse.js";
|
|
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
|
-
}
|
|
22
|
-
};
|
|
23
|
-
//#endregion
|
|
24
|
-
export { t as BadGateway };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { BadResponse as e } from "./_badResponse.js";
|
|
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
|
-
}
|
|
22
|
-
};
|
|
23
|
-
//#endregion
|
|
24
|
-
export { t as BadRequest };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { BadResponse as e } from "./_badResponse.js";
|
|
2
|
-
//#region src/http/badResponses/conflict.ts
|
|
3
|
-
var t = class extends e {
|
|
4
|
-
constructor(e, t) {
|
|
5
|
-
super(), this.name = "Conflict", this.status = 409, this.statusText = e, this.debugColor = "yellow", 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
|
-
}
|
|
22
|
-
};
|
|
23
|
-
//#endregion
|
|
24
|
-
export { t as Conflict };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { BadResponse as e } from "./_badResponse.js";
|
|
2
|
-
//#region src/http/badResponses/forbidden.ts
|
|
3
|
-
var t = class extends e {
|
|
4
|
-
constructor(e, t) {
|
|
5
|
-
super(), this.name = "Forbidden", this.status = 403, 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
|
-
}
|
|
22
|
-
};
|
|
23
|
-
//#endregion
|
|
24
|
-
export { t as Forbidden };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { BadResponse as e } from "./_badResponse.js";
|
|
2
|
-
//#region src/http/badResponses/notFound.ts
|
|
3
|
-
var t = class extends e {
|
|
4
|
-
constructor(e, t) {
|
|
5
|
-
super(), this.name = "NotFound", this.status = 404, 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
|
-
}
|
|
22
|
-
};
|
|
23
|
-
//#endregion
|
|
24
|
-
export { t as NotFound };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { BadResponse as e } from "./_badResponse.js";
|
|
2
|
-
//#region src/http/badResponses/notImplemented.ts
|
|
3
|
-
var t = class extends e {
|
|
4
|
-
constructor(e, t) {
|
|
5
|
-
super(), this.name = "NotImplemented", this.status = 501, 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
|
-
}
|
|
22
|
-
};
|
|
23
|
-
//#endregion
|
|
24
|
-
export { t as NotImplemented };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { BadResponse as e } from "./_badResponse.js";
|
|
2
|
-
//#region src/http/badResponses/serverError.ts
|
|
3
|
-
var t = class extends e {
|
|
4
|
-
constructor(e, t) {
|
|
5
|
-
super(), this.name = "ServerError", this.status = 500, 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
|
-
}
|
|
22
|
-
};
|
|
23
|
-
//#endregion
|
|
24
|
-
export { t as ServerError };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { BadResponse as e } from "./_badResponse.js";
|
|
2
|
-
//#region src/http/badResponses/unauthorized.ts
|
|
3
|
-
var t = class extends e {
|
|
4
|
-
constructor(e, t) {
|
|
5
|
-
super(), this.name = "Unauthorized", this.status = 401, this.statusText = e, this.debugColor = "yellow", 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
|
-
}
|
|
22
|
-
};
|
|
23
|
-
//#endregion
|
|
24
|
-
export { t as Unauthorized };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { BadResponse as e } from "./_badResponse.js";
|
|
2
|
-
//#region src/http/badResponses/unprocessableEntity.ts
|
|
3
|
-
var t = class extends e {
|
|
4
|
-
constructor(e) {
|
|
5
|
-
super(), this.name = "UnprocessableEntity", this.status = 422, this.statusText = e.message || "Unprocessable entity", this.debugColor = "yellow", this.cause = {
|
|
6
|
-
data: e.data,
|
|
7
|
-
fieldErrors: e.fieldErrors,
|
|
8
|
-
fields: e.fields
|
|
9
|
-
}, this.onDebug();
|
|
10
|
-
}
|
|
11
|
-
toResponse() {
|
|
12
|
-
let e = {
|
|
13
|
-
headers: { "Content-Type": "application/json" },
|
|
14
|
-
status: this.status,
|
|
15
|
-
statusText: this.statusText
|
|
16
|
-
};
|
|
17
|
-
return new Response(JSON.stringify(this.makeBody()), e);
|
|
18
|
-
}
|
|
19
|
-
toJson() {
|
|
20
|
-
let e = {
|
|
21
|
-
status: this.status,
|
|
22
|
-
statusText: this.statusText
|
|
23
|
-
};
|
|
24
|
-
return Response.json(this.makeBody(), e);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
//#endregion
|
|
28
|
-
export { t as UnprocessableEntity };
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { DebugService as e } from "../../services/debugService.js";
|
|
2
|
-
import { flushDebugLogs as t } from "../../utilities/flushDebugLogs.js";
|
|
3
|
-
//#region src/http/successResponses/_successResponse.ts
|
|
4
|
-
var n = class {
|
|
5
|
-
_body = null;
|
|
6
|
-
_name = "SuccessResponse";
|
|
7
|
-
_status = 200;
|
|
8
|
-
_statusText = "OK";
|
|
9
|
-
_debugColor = "green";
|
|
10
|
-
get body() {
|
|
11
|
-
return this._body;
|
|
12
|
-
}
|
|
13
|
-
set body(e) {
|
|
14
|
-
this._body = e ?? null;
|
|
15
|
-
}
|
|
16
|
-
get name() {
|
|
17
|
-
return this._name;
|
|
18
|
-
}
|
|
19
|
-
set name(e) {
|
|
20
|
-
this._name = e;
|
|
21
|
-
}
|
|
22
|
-
get status() {
|
|
23
|
-
return this._status;
|
|
24
|
-
}
|
|
25
|
-
set status(e) {
|
|
26
|
-
this._status = e;
|
|
27
|
-
}
|
|
28
|
-
get statusText() {
|
|
29
|
-
return this._statusText;
|
|
30
|
-
}
|
|
31
|
-
set statusText(e) {
|
|
32
|
-
this._statusText = e;
|
|
33
|
-
}
|
|
34
|
-
get debugColor() {
|
|
35
|
-
return this._debugColor;
|
|
36
|
-
}
|
|
37
|
-
set debugColor(e) {
|
|
38
|
-
[
|
|
39
|
-
"green",
|
|
40
|
-
"yellow",
|
|
41
|
-
"cyan",
|
|
42
|
-
"red"
|
|
43
|
-
].includes(e) && (this._debugColor = e);
|
|
44
|
-
}
|
|
45
|
-
onDebug(n) {
|
|
46
|
-
let r = [], { callerInfo: i, functionName: a } = e.getCaller();
|
|
47
|
-
r.push(`Caller Function: ${a}`), r.push(`Caller Location: ${i}`), this.statusText && r.push(`Message: ${this.statusText}`), n && r.push(`Body: ${JSON.stringify(n)}`), t({
|
|
48
|
-
scheme: this._debugColor,
|
|
49
|
-
name: this.name,
|
|
50
|
-
debugs: r
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
makeBody() {
|
|
54
|
-
return {
|
|
55
|
-
name: this.name,
|
|
56
|
-
message: this.statusText,
|
|
57
|
-
body: this.body
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
//#endregion
|
|
62
|
-
export { n as SuccessResponse };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { SuccessResponse as e } from "./_successResponse.js";
|
|
2
|
-
//#region src/http/successResponses/created.ts
|
|
3
|
-
var t = class extends e {
|
|
4
|
-
constructor(e, t) {
|
|
5
|
-
super(), this.name = "Created", this.status = 201, this.statusText = e, this.body = 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.body), e);
|
|
14
|
-
}
|
|
15
|
-
toJson() {
|
|
16
|
-
let e = {
|
|
17
|
-
status: this.status,
|
|
18
|
-
statusText: this.statusText
|
|
19
|
-
};
|
|
20
|
-
return Response.json(this.body, e);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
//#endregion
|
|
24
|
-
export { t as Created };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { SuccessResponse as e } from "./_successResponse.js";
|
|
2
|
-
//#region src/http/successResponses/found.ts
|
|
3
|
-
var t = class extends e {
|
|
4
|
-
constructor(e, t) {
|
|
5
|
-
super(), this.name = "Found", this.status = 302, this.statusText = e, this.body = 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.body), e);
|
|
14
|
-
}
|
|
15
|
-
toJson() {
|
|
16
|
-
let e = {
|
|
17
|
-
status: this.status,
|
|
18
|
-
statusText: this.statusText
|
|
19
|
-
};
|
|
20
|
-
return Response.json(this.body, e);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
//#endregion
|
|
24
|
-
export { t as Found };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { SuccessResponse as e } from "./_successResponse.js";
|
|
2
|
-
//#region src/http/successResponses/noContent.ts
|
|
3
|
-
var t = class extends e {
|
|
4
|
-
constructor(e) {
|
|
5
|
-
super(), this.name = "NoContent", this.status = 204, this.statusText = e, 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(null, e);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
//#endregion
|
|
17
|
-
export { t as NoContent };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { SuccessResponse as e } from "./_successResponse.js";
|
|
2
|
-
//#region src/http/successResponses/success.ts
|
|
3
|
-
var t = class extends e {
|
|
4
|
-
constructor(e, t) {
|
|
5
|
-
super(), this.name = "Success", this.status = 200, this.statusText = e, this.body = 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.body), e);
|
|
14
|
-
}
|
|
15
|
-
toJson() {
|
|
16
|
-
let e = {
|
|
17
|
-
status: this.status,
|
|
18
|
-
statusText: this.statusText
|
|
19
|
-
};
|
|
20
|
-
return Response.json(this.body, e);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
//#endregion
|
|
24
|
-
export { t as Success };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { SuccessResponse as e } from "./_successResponse.js";
|
|
2
|
-
//#region src/http/successResponses/updated.ts
|
|
3
|
-
var t = class extends e {
|
|
4
|
-
constructor(e, t) {
|
|
5
|
-
super(), this.name = "Updated", this.status = 200, this.statusText = e, this.body = 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.body), e);
|
|
14
|
-
}
|
|
15
|
-
toJson() {
|
|
16
|
-
let e = {
|
|
17
|
-
status: this.status,
|
|
18
|
-
statusText: this.statusText
|
|
19
|
-
};
|
|
20
|
-
return Response.json(this.body, e);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
//#endregion
|
|
24
|
-
export { t as Updated };
|