@arkyn/server 3.0.1-beta.61 → 3.0.1-beta.63

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.
Files changed (75) hide show
  1. package/dist/api/arkynLogRequest.d.ts.map +1 -1
  2. package/dist/api/arkynLogRequest.js +8 -3
  3. package/dist/api/makeRequest.d.ts.map +1 -1
  4. package/dist/api/makeRequest.js +6 -2
  5. package/dist/bundle.js +484 -393
  6. package/dist/bundle.umd.cjs +14 -8
  7. package/dist/http/badResponses/_badResponse.d.ts +22 -0
  8. package/dist/http/badResponses/_badResponse.d.ts.map +1 -0
  9. package/dist/http/badResponses/_badResponse.js +33 -0
  10. package/dist/http/badResponses/badGateway.d.ts +2 -1
  11. package/dist/http/badResponses/badGateway.d.ts.map +1 -1
  12. package/dist/http/badResponses/badGateway.js +4 -3
  13. package/dist/http/badResponses/badRequest.d.ts +2 -1
  14. package/dist/http/badResponses/badRequest.d.ts.map +1 -1
  15. package/dist/http/badResponses/badRequest.js +4 -3
  16. package/dist/http/badResponses/conflict.d.ts +2 -1
  17. package/dist/http/badResponses/conflict.d.ts.map +1 -1
  18. package/dist/http/badResponses/conflict.js +4 -3
  19. package/dist/http/badResponses/forbidden.d.ts +2 -1
  20. package/dist/http/badResponses/forbidden.d.ts.map +1 -1
  21. package/dist/http/badResponses/forbidden.js +4 -3
  22. package/dist/http/badResponses/notFound.d.ts +2 -1
  23. package/dist/http/badResponses/notFound.d.ts.map +1 -1
  24. package/dist/http/badResponses/notFound.js +4 -3
  25. package/dist/http/badResponses/notImplemented.d.ts +2 -1
  26. package/dist/http/badResponses/notImplemented.d.ts.map +1 -1
  27. package/dist/http/badResponses/notImplemented.js +4 -3
  28. package/dist/http/badResponses/serverError.d.ts +2 -1
  29. package/dist/http/badResponses/serverError.d.ts.map +1 -1
  30. package/dist/http/badResponses/serverError.js +4 -3
  31. package/dist/http/badResponses/unauthorized.d.ts +2 -1
  32. package/dist/http/badResponses/unauthorized.d.ts.map +1 -1
  33. package/dist/http/badResponses/unauthorized.js +4 -3
  34. package/dist/http/badResponses/unprocessableEntity.d.ts +3 -2
  35. package/dist/http/badResponses/unprocessableEntity.d.ts.map +1 -1
  36. package/dist/http/badResponses/unprocessableEntity.js +5 -4
  37. package/dist/http/successResponses/_successResponse.d.ts +22 -0
  38. package/dist/http/successResponses/_successResponse.d.ts.map +1 -0
  39. package/dist/http/successResponses/_successResponse.js +37 -0
  40. package/dist/http/successResponses/created.d.ts +2 -1
  41. package/dist/http/successResponses/created.d.ts.map +1 -1
  42. package/dist/http/successResponses/created.js +4 -1
  43. package/dist/http/successResponses/found.d.ts +2 -1
  44. package/dist/http/successResponses/found.d.ts.map +1 -1
  45. package/dist/http/successResponses/found.js +4 -1
  46. package/dist/http/successResponses/noContent.d.ts +2 -1
  47. package/dist/http/successResponses/noContent.d.ts.map +1 -1
  48. package/dist/http/successResponses/noContent.js +4 -1
  49. package/dist/http/successResponses/success.d.ts +2 -1
  50. package/dist/http/successResponses/success.d.ts.map +1 -1
  51. package/dist/http/successResponses/success.js +4 -1
  52. package/dist/http/successResponses/updated.d.ts +2 -1
  53. package/dist/http/successResponses/updated.d.ts.map +1 -1
  54. package/dist/http/successResponses/updated.js +4 -1
  55. package/dist/index.d.ts +2 -1
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +2 -1
  58. package/dist/services/apiService.d.ts.map +1 -1
  59. package/dist/services/apiService.js +8 -8
  60. package/dist/services/debugService.d.ts +54 -0
  61. package/dist/services/debugService.d.ts.map +1 -0
  62. package/dist/services/debugService.js +57 -0
  63. package/dist/services/flushDebugLogs.d.ts +8 -0
  64. package/dist/services/flushDebugLogs.d.ts.map +1 -0
  65. package/dist/services/flushDebugLogs.js +21 -0
  66. package/dist/services/formParse.d.ts.map +1 -1
  67. package/dist/services/formParse.js +0 -1
  68. package/dist/services/getCaller.d.ts.map +1 -1
  69. package/dist/services/getCaller.js +4 -4
  70. package/dist/services/schemaValidator.d.ts.map +1 -1
  71. package/dist/services/schemaValidator.js +1 -3
  72. package/package.json +1 -1
  73. package/dist/services/httpDebug.d.ts +0 -74
  74. package/dist/services/httpDebug.d.ts.map +0 -1
  75. package/dist/services/httpDebug.js +0 -93
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Base class for handling bad HTTP responses with debugging capabilities.
3
+ * Provides logging functionality to track response errors and their context.
4
+ */
5
+ declare class SuccessResponse {
6
+ /**
7
+ * Logs debug information for success responses including caller context and response details.
8
+ *
9
+ * @param name - The name/type of the success response being logged
10
+ * @param body - The response body or success data to be logged
11
+ * @param cause - Optional additional cause information for the error
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const SuccessResponse = new SuccessResponse();
16
+ * SuccessResponse.onDebug("ValidationError", { field: "email", message: "Invalid format" });
17
+ * ```
18
+ */
19
+ onDebug(name: string, body: any, cause?: any): void;
20
+ }
21
+ export { SuccessResponse };
22
+ //# sourceMappingURL=_successResponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_successResponse.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/_successResponse.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,cAAM,eAAe;IACnB;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG;CAgB7C;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { flushDebugLogs } from "../../services/flushDebugLogs";
2
+ import { getCaller } from "../../services/getCaller";
3
+ /**
4
+ * Base class for handling bad HTTP responses with debugging capabilities.
5
+ * Provides logging functionality to track response errors and their context.
6
+ */
7
+ class SuccessResponse {
8
+ /**
9
+ * Logs debug information for success responses including caller context and response details.
10
+ *
11
+ * @param name - The name/type of the success response being logged
12
+ * @param body - The response body or success data to be logged
13
+ * @param cause - Optional additional cause information for the error
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const SuccessResponse = new SuccessResponse();
18
+ * SuccessResponse.onDebug("ValidationError", { field: "email", message: "Invalid format" });
19
+ * ```
20
+ */
21
+ onDebug(name, body, cause) {
22
+ const debugs = [];
23
+ const { callerInfo, functionName } = getCaller();
24
+ debugs.push(`${name} initialized\n`);
25
+ debugs.push(`Caller Function: ${functionName}\n`);
26
+ debugs.push(`Caller Location: ${callerInfo}\n`);
27
+ debugs.push(`Body: ${JSON.stringify(body, null, 2)}\n`);
28
+ if (cause)
29
+ debugs.push(`Cause: ${JSON.stringify(cause, null, 2)}\n`);
30
+ flushDebugLogs({
31
+ scheme: "green",
32
+ name: "ARKYN-SUCCESS-RESPONSE-DEBUG",
33
+ debugs,
34
+ });
35
+ }
36
+ }
37
+ export { SuccessResponse };
@@ -1,3 +1,4 @@
1
+ import { SuccessResponse } from "./_successResponse";
1
2
  /**
2
3
  * Represents a successful HTTP response with a status code of 201 (Created).
3
4
  * This class is used to standardize the structure of a "Created" response,
@@ -5,7 +6,7 @@
5
6
  *
6
7
  * @template T - The type of the response body.
7
8
  */
8
- declare class Created<T> {
9
+ declare class Created<T> extends SuccessResponse {
9
10
  body: T;
10
11
  headers: ResponseInit["headers"];
11
12
  status: number;
@@ -1 +1 @@
1
- {"version":3,"file":"created.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/created.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAM,OAAO,CAAC,CAAC;IACb,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,YAAY;IAOxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CASnB;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"created.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/created.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;GAMG;AAEH,cAAM,OAAO,CAAC,CAAC,CAAE,SAAQ,eAAe;IACtC,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,YAAY;IAWxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CASnB;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { SuccessResponse } from "./_successResponse";
1
2
  /**
2
3
  * Represents a successful HTTP response with a status code of 201 (Created).
3
4
  * This class is used to standardize the structure of a "Created" response,
@@ -5,7 +6,7 @@
5
6
  *
6
7
  * @template T - The type of the response body.
7
8
  */
8
- class Created {
9
+ class Created extends SuccessResponse {
9
10
  body;
10
11
  headers;
11
12
  status;
@@ -17,10 +18,12 @@ class Created {
17
18
  * @param init - Optional initialization object for customizing headers, status, and status text.
18
19
  */
19
20
  constructor(body, init) {
21
+ super();
20
22
  this.body = body;
21
23
  this.headers = init?.headers || {};
22
24
  this.status = init?.status || 201;
23
25
  this.statusText = init?.statusText || "Resource created successfully";
26
+ this.onDebug("Created", body);
24
27
  }
25
28
  /**
26
29
  * Converts the `Created` instance into a `Response` object with a JSON body.
@@ -1,3 +1,4 @@
1
+ import { SuccessResponse } from "./_successResponse";
1
2
  /**
2
3
  * Represents an HTTP 302 Found response.
3
4
  * This class is used to create a standardized HTTP response with a status of 302 (Found),
@@ -5,7 +6,7 @@
5
6
  *
6
7
  * @template T - The type of the response body.
7
8
  */
8
- declare class Found<T> {
9
+ declare class Found<T> extends SuccessResponse {
9
10
  body: T;
10
11
  headers: ResponseInit["headers"];
11
12
  status: number;
@@ -1 +1 @@
1
- {"version":3,"file":"found.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/found.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAM,KAAK,CAAC,CAAC;IACX,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;;;;OAQG;gBAES,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,YAAY;IAOxC;;;;;OAKG;IAEH,UAAU;IAUV;;;;;OAKG;IAEH,MAAM;CASP;AAED,OAAO,EAAE,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"found.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/found.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;GAMG;AAEH,cAAM,KAAK,CAAC,CAAC,CAAE,SAAQ,eAAe;IACpC,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;;;;OAQG;gBAES,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,YAAY;IAWxC;;;;;OAKG;IAEH,UAAU;IAUV;;;;;OAKG;IAEH,MAAM;CASP;AAED,OAAO,EAAE,KAAK,EAAE,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { SuccessResponse } from "./_successResponse";
1
2
  /**
2
3
  * Represents an HTTP 302 Found response.
3
4
  * This class is used to create a standardized HTTP response with a status of 302 (Found),
@@ -5,7 +6,7 @@
5
6
  *
6
7
  * @template T - The type of the response body.
7
8
  */
8
- class Found {
9
+ class Found extends SuccessResponse {
9
10
  body;
10
11
  headers;
11
12
  status;
@@ -20,10 +21,12 @@ class Found {
20
21
  * - `statusText`: HTTP status text (default is "Found").
21
22
  */
22
23
  constructor(body, init) {
24
+ super();
23
25
  this.body = body;
24
26
  this.headers = init?.headers || {};
25
27
  this.status = init?.status || 302;
26
28
  this.statusText = init?.statusText || "Found";
29
+ this.onDebug("Found", body);
27
30
  }
28
31
  /**
29
32
  * Converts the `Found` instance into a `Response` object.
@@ -1,9 +1,10 @@
1
+ import { SuccessResponse } from "./_successResponse";
1
2
  /**
2
3
  * Represents a successful HTTP response with a status code of 204 (No Content).
3
4
  * This class is used to standardize the structure of a "No Content" response,
4
5
  * including headers, status, and status text.
5
6
  */
6
- declare class NoContent {
7
+ declare class NoContent extends SuccessResponse {
7
8
  headers: ResponseInit["headers"];
8
9
  status: number;
9
10
  statusText: string;
@@ -1 +1 @@
1
- {"version":3,"file":"noContent.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/noContent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAM,SAAS;IACb,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;gBAES,IAAI,CAAC,EAAE,YAAY;IAM/B;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;CASvB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"noContent.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/noContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;GAIG;AAEH,cAAM,SAAU,SAAQ,eAAe;IACrC,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;gBAES,IAAI,CAAC,EAAE,YAAY;IAU/B;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;CASvB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -1,9 +1,10 @@
1
+ import { SuccessResponse } from "./_successResponse";
1
2
  /**
2
3
  * Represents a successful HTTP response with a status code of 204 (No Content).
3
4
  * This class is used to standardize the structure of a "No Content" response,
4
5
  * including headers, status, and status text.
5
6
  */
6
- class NoContent {
7
+ class NoContent extends SuccessResponse {
7
8
  headers;
8
9
  status;
9
10
  statusText;
@@ -13,9 +14,11 @@ class NoContent {
13
14
  * @param init - Optional initialization object for customizing headers, status, and status text.
14
15
  */
15
16
  constructor(init) {
17
+ super();
16
18
  this.headers = init?.headers || {};
17
19
  this.status = init?.status || 204;
18
20
  this.statusText = init?.statusText ?? "No content";
21
+ this.onDebug("No content", null);
19
22
  }
20
23
  /**
21
24
  * Converts the `NoContent` instance into a `Response` object.
@@ -1,3 +1,4 @@
1
+ import { SuccessResponse } from "./_successResponse";
1
2
  /**
2
3
  * Represents a successful HTTP response with a status code of 200 (OK).
3
4
  * This class is used to standardize the structure of a "Success" response,
@@ -5,7 +6,7 @@
5
6
  *
6
7
  * @template T - The type of the response body.
7
8
  */
8
- declare class Success<T> {
9
+ declare class Success<T> extends SuccessResponse {
9
10
  body: T;
10
11
  headers: ResponseInit["headers"];
11
12
  status: number;
@@ -1 +1 @@
1
- {"version":3,"file":"success.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/success.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAM,OAAO,CAAC,CAAC;IACb,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,YAAY;IAOxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CASnB;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"success.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/success.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;GAMG;AAEH,cAAM,OAAO,CAAC,CAAC,CAAE,SAAQ,eAAe;IACtC,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,YAAY;IAWxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CASnB;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { SuccessResponse } from "./_successResponse";
1
2
  /**
2
3
  * Represents a successful HTTP response with a status code of 200 (OK).
3
4
  * This class is used to standardize the structure of a "Success" response,
@@ -5,7 +6,7 @@
5
6
  *
6
7
  * @template T - The type of the response body.
7
8
  */
8
- class Success {
9
+ class Success extends SuccessResponse {
9
10
  body;
10
11
  headers;
11
12
  status;
@@ -17,10 +18,12 @@ class Success {
17
18
  * @param init - Optional initialization object for customizing headers, status, and status text.
18
19
  */
19
20
  constructor(body, init) {
21
+ super();
20
22
  this.body = body;
21
23
  this.headers = init?.headers || {};
22
24
  this.status = init?.status || 200;
23
25
  this.statusText = init?.statusText ?? "OK";
26
+ this.onDebug("Success", body);
24
27
  }
25
28
  /**
26
29
  * Converts the `Success` instance into a `Response` object with a JSON body.
@@ -1,3 +1,4 @@
1
+ import { SuccessResponse } from "./_successResponse";
1
2
  /**
2
3
  * Represents a successful HTTP response with a status code of 200 (OK) or other custom status codes.
3
4
  * This class is used to standardize the structure of an "Updated" response,
@@ -5,7 +6,7 @@
5
6
  *
6
7
  * @template T - The type of the response body.
7
8
  */
8
- declare class Updated<T> {
9
+ declare class Updated<T> extends SuccessResponse {
9
10
  body: T;
10
11
  headers: ResponseInit["headers"];
11
12
  status: number;
@@ -1 +1 @@
1
- {"version":3,"file":"updated.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/updated.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAM,OAAO,CAAC,CAAC;IACb,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,YAAY;IAOxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CASnB;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"updated.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/updated.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;GAMG;AAEH,cAAM,OAAO,CAAC,CAAC,CAAE,SAAQ,eAAe;IACtC,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,YAAY;IAWxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CASnB;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { SuccessResponse } from "./_successResponse";
1
2
  /**
2
3
  * Represents a successful HTTP response with a status code of 200 (OK) or other custom status codes.
3
4
  * This class is used to standardize the structure of an "Updated" response,
@@ -5,7 +6,7 @@
5
6
  *
6
7
  * @template T - The type of the response body.
7
8
  */
8
- class Updated {
9
+ class Updated extends SuccessResponse {
9
10
  body;
10
11
  headers;
11
12
  status;
@@ -17,10 +18,12 @@ class Updated {
17
18
  * @param init - Optional initialization object for customizing headers, status, and status text.
18
19
  */
19
20
  constructor(body, init) {
21
+ super();
20
22
  this.body = body;
21
23
  this.headers = init?.headers || {};
22
24
  this.status = init?.status || 200;
23
25
  this.statusText = init?.statusText || "Resource updated successfully";
26
+ this.onDebug("Updated", body);
24
27
  }
25
28
  /**
26
29
  * Converts the `Updated` instance into a `Response` object with a JSON body.
package/dist/index.d.ts CHANGED
@@ -14,12 +14,13 @@ export { Success } from "./http/successResponses/success";
14
14
  export { Updated } from "./http/successResponses/updated";
15
15
  export { ApiService } from "./services/apiService";
16
16
  export { ArkynLogService } from "./services/arkynLogService";
17
+ export { DebugService } from "./services/debugService";
17
18
  export { decodeErrorMessageFromRequest } from "./services/decodeErrorMessageFromRequest";
18
19
  export { decodeRequestBody } from "./services/decodeRequestBody";
19
20
  export { errorHandler } from "./services/errorHandler";
21
+ export { flushDebugLogs } from "./services/flushDebugLogs";
20
22
  export { formParse } from "./services/formParse";
21
23
  export { getCaller } from "./services/getCaller";
22
24
  export { getScopedParams } from "./services/getScopedParams";
23
- export { httpDebug, HttpDebugService } from "./services/httpDebug";
24
25
  export { SchemaValidator } from "./services/schemaValidator";
25
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO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11 +17,12 @@ export { Updated } from "./http/successResponses/updated";
17
17
  // services
18
18
  export { ApiService } from "./services/apiService";
19
19
  export { ArkynLogService } from "./services/arkynLogService";
20
+ export { DebugService } from "./services/debugService";
20
21
  export { decodeErrorMessageFromRequest } from "./services/decodeErrorMessageFromRequest";
21
22
  export { decodeRequestBody } from "./services/decodeRequestBody";
22
23
  export { errorHandler } from "./services/errorHandler";
24
+ export { flushDebugLogs } from "./services/flushDebugLogs";
23
25
  export { formParse } from "./services/formParse";
24
26
  export { getCaller } from "./services/getCaller";
25
27
  export { getScopedParams } from "./services/getScopedParams";
26
- export { httpDebug, HttpDebugService } from "./services/httpDebug";
27
28
  export { SchemaValidator } from "./services/schemaValidator";
@@ -1 +1 @@
1
- {"version":3,"file":"apiService.d.ts","sourceRoot":"","sources":["../../src/services/apiService.ts"],"names":[],"mappings":"AAMA,KAAK,0BAA0B,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,KAAK,8BAA8B,GAAG;IACpC,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AAEH,cAAM,UAAU;IACd,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAC,CAAc;IAClC,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,WAAW,CAAC,CAAU;IAE9B;;;;;;;OAOG;gBAES,KAAK,EAAE,0BAA0B;IAO7C;;;;OAIG;IAEH,OAAO,CAAC,OAA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CAAU;IAE9B;;;;;;;OAOG;gBAES,KAAK,EAAE,0BAA0B;IAO7C;;;;OAIG;IAEH,OAAO,CAAC,OAAO;IAcf,OAAO,CAAC,WAAW;IAInB;;;;;OAKG;IAEH,OAAO,CAAC,eAAe;IAcvB;;;;;OAKG;IAEG,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,8BAA8B;IAQ9D;;;;;OAKG;IAEG,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;IAS5D;;;;;OAKG;IAEG,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;IAS3D;;;;;OAKG;IAEG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;IAS7D;;;;;OAKG;IAEG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;CAQ/D;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -3,6 +3,7 @@ import { getRequest } from "../api/getRequest";
3
3
  import { patchRequest } from "../api/patchRequest";
4
4
  import { postRequest } from "../api/postRequest";
5
5
  import { putRequest } from "../api/putRequest";
6
+ import { flushDebugLogs } from "./flushDebugLogs";
6
7
  /**
7
8
  * Class representing an API instance to handle HTTP requests with base configurations.
8
9
  */
@@ -32,16 +33,15 @@ class ApiService {
32
33
  */
33
34
  onDebug(fullRoute, method, data) {
34
35
  if (this.enableDebug) {
35
- const reset = "\x1b[0m";
36
- const yellow = "\x1b[33m";
37
- const debugName = `${yellow}[ARKYN-API-DEBUG]${reset}`;
38
- console.log(`${debugName} Base URL: ${this.baseUrl}`);
39
- console.log(`${debugName} Full URL: ${fullRoute}`);
40
- console.log(`${debugName} Method: ${method}`);
36
+ const debugs = [];
37
+ debugs.push(`Base URL: ${this.baseUrl}`);
38
+ debugs.push(`Full URL: ${fullRoute}`);
39
+ debugs.push(`Method: ${method}`);
41
40
  if (data[0])
42
- console.log(`${debugName} Headers: `, data[0]);
41
+ debugs.push(`Headers: ${JSON.stringify(data[0])}`);
43
42
  if (data[1])
44
- console.log(`${debugName} Body: `, data[1]);
43
+ debugs.push(`Body: ${JSON.stringify(data[1])}`);
44
+ flushDebugLogs({ debugs, name: "ARKYN-API-DEBUG", scheme: "yellow" });
45
45
  }
46
46
  }
47
47
  generateURL(route) {
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Service for managing HTTP debug configuration and behavior.
3
+ *
4
+ * This service provides functionality to configure how the `getCaller` function
5
+ * identifies the actual caller in the stack trace by allowing specific files
6
+ * to be ignored during stack trace analysis.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // Configure to ignore httpAdapter.ts in stack traces
11
+ * HttpDebugService.setIgnoreFile("httpAdapter.ts");
12
+ *
13
+ * // Now when httpDebug is called from within httpAdapter.ts,
14
+ * // it will show the actual caller (e.g., cart.ts) instead
15
+ * ```
16
+ */
17
+ declare class DebugService {
18
+ /**
19
+ * The name of the file to ignore when analyzing the stack trace.
20
+ * When set, the `getCaller` function will skip stack frames containing this file name.
21
+ */
22
+ static ignoreFiles: string[];
23
+ /**
24
+ * Sets the file name to be ignored during stack trace analysis.
25
+ *
26
+ * This method configures the debug service to skip specific files when
27
+ * determining the actual caller of a function. This is useful when you have
28
+ * adapter or wrapper functions that you want to be transparent in the debug output.
29
+ *
30
+ * @param file - The name of the file to ignore in stack traces (e.g., "httpAdapter.ts")
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * // Ignore the HTTP adapter file so debug shows the actual business logic caller
35
+ * DebugService.setIgnoreFile("httpAdapter.ts");
36
+ * ```
37
+ */
38
+ static setIgnoreFile(file: string): void;
39
+ /**
40
+ * Clears all configured ignore files.
41
+ *
42
+ * This method resets the ignore file configuration, allowing all files to be
43
+ * considered in stack trace analysis again.
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * // Clear all ignore file configurations
48
+ * DebugService.clearIgnoreFiles();
49
+ * ```
50
+ */
51
+ static clearIgnoreFiles(): void;
52
+ }
53
+ export { DebugService };
54
+ //# sourceMappingURL=debugService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debugService.d.ts","sourceRoot":"","sources":["../../src/services/debugService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,cAAM,YAAY;IAChB;;;OAGG;IACH,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,CAAM;IAElC;;;;;;;;;;;;;;OAcG;IAEH,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM;IAIjC;;;;;;;;;;;OAWG;IAEH,MAAM,CAAC,gBAAgB;CAGxB;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Service for managing HTTP debug configuration and behavior.
3
+ *
4
+ * This service provides functionality to configure how the `getCaller` function
5
+ * identifies the actual caller in the stack trace by allowing specific files
6
+ * to be ignored during stack trace analysis.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // Configure to ignore httpAdapter.ts in stack traces
11
+ * HttpDebugService.setIgnoreFile("httpAdapter.ts");
12
+ *
13
+ * // Now when httpDebug is called from within httpAdapter.ts,
14
+ * // it will show the actual caller (e.g., cart.ts) instead
15
+ * ```
16
+ */
17
+ class DebugService {
18
+ /**
19
+ * The name of the file to ignore when analyzing the stack trace.
20
+ * When set, the `getCaller` function will skip stack frames containing this file name.
21
+ */
22
+ static ignoreFiles = [];
23
+ /**
24
+ * Sets the file name to be ignored during stack trace analysis.
25
+ *
26
+ * This method configures the debug service to skip specific files when
27
+ * determining the actual caller of a function. This is useful when you have
28
+ * adapter or wrapper functions that you want to be transparent in the debug output.
29
+ *
30
+ * @param file - The name of the file to ignore in stack traces (e.g., "httpAdapter.ts")
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * // Ignore the HTTP adapter file so debug shows the actual business logic caller
35
+ * DebugService.setIgnoreFile("httpAdapter.ts");
36
+ * ```
37
+ */
38
+ static setIgnoreFile(file) {
39
+ this.ignoreFiles.push(file);
40
+ }
41
+ /**
42
+ * Clears all configured ignore files.
43
+ *
44
+ * This method resets the ignore file configuration, allowing all files to be
45
+ * considered in stack trace analysis again.
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * // Clear all ignore file configurations
50
+ * DebugService.clearIgnoreFiles();
51
+ * ```
52
+ */
53
+ static clearIgnoreFiles() {
54
+ this.ignoreFiles = [];
55
+ }
56
+ }
57
+ export { DebugService };
@@ -0,0 +1,8 @@
1
+ type FlushDebugLogsProps = {
2
+ scheme: "yellow" | "cyan" | "red" | "green";
3
+ name: string;
4
+ debugs: string[];
5
+ };
6
+ declare function flushDebugLogs(props: FlushDebugLogsProps): void;
7
+ export { flushDebugLogs };
8
+ //# sourceMappingURL=flushDebugLogs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flushDebugLogs.d.ts","sourceRoot":"","sources":["../../src/services/flushDebugLogs.ts"],"names":[],"mappings":"AAAA,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,iBAAS,cAAc,CAAC,KAAK,EAAE,mBAAmB,QA0BjD;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,21 @@
1
+ function flushDebugLogs(props) {
2
+ const isDebugMode = process.env.NODE_ENV === "development" ||
3
+ process.env?.SHOW_ERRORS_IN_CONSOLE === "true";
4
+ if (isDebugMode) {
5
+ const reset = "\x1b[0m";
6
+ const colors = {
7
+ yellow: "\x1b[33m",
8
+ cyan: "\x1b[36m",
9
+ red: "\x1b[31m",
10
+ green: "\x1b[32m",
11
+ };
12
+ const debugName = `${colors[props.scheme]}[${props.name}]${reset}`;
13
+ let consoleData = `<------------------->`;
14
+ props.debugs.forEach((debug) => {
15
+ consoleData += `${debugName} ${debug}\n`;
16
+ });
17
+ consoleData += `<------------------->`;
18
+ console.log(consoleData);
19
+ }
20
+ }
21
+ export { flushDebugLogs };
@@ -1 +1 @@
1
- {"version":3,"file":"formParse.d.ts","sourceRoot":"","sources":["../../src/services/formParse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC,KAAK,eAAe,CAAC,CAAC,SAAS,cAAc,IAAI;IAC/C,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;CACjD,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAChC,WAAW,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACtC,CAAC;AAEF,KAAK,cAAc,GAAG,CAAC,QAAQ,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAExE,KAAK,mBAAmB,CAAC,CAAC,SAAS,cAAc,IAC7C,eAAe,CAAC,CAAC,CAAC,GAClB,aAAa,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,iBAAS,SAAS,CAAC,CAAC,SAAS,cAAc,EAAE,CAC3C,QAAQ,EACR,MAAM,EACP,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAsB5B;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"formParse.d.ts","sourceRoot":"","sources":["../../src/services/formParse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC,KAAK,eAAe,CAAC,CAAC,SAAS,cAAc,IAAI;IAC/C,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;CACjD,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAChC,WAAW,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACtC,CAAC;AAEF,KAAK,cAAc,GAAG,CAAC,QAAQ,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAExE,KAAK,mBAAmB,CAAC,CAAC,SAAS,cAAc,IAC7C,eAAe,CAAC,CAAC,CAAC,GAClB,aAAa,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,iBAAS,SAAS,CAAC,CAAC,SAAS,cAAc,EAAE,CAC3C,QAAQ,EACR,MAAM,EACP,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAqB5B;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -40,7 +40,6 @@ function formParse([formData, schema,]) {
40
40
  const zodResponse = schema.safeParse(formData);
41
41
  if (zodResponse.success === false) {
42
42
  const errorsObject = Object.fromEntries(zodResponse.error.issues.map((item) => {
43
- console.log(item);
44
43
  return [item.path.join("."), item.message];
45
44
  }));
46
45
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"getCaller.d.ts","sourceRoot":"","sources":["../../src/services/getCaller.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AAEH,iBAAS,SAAS;;;EA+DjB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"getCaller.d.ts","sourceRoot":"","sources":["../../src/services/getCaller.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AAEH,iBAAS,SAAS;;;EAiEjB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import { HttpDebugService } from "./httpDebug";
2
+ import { DebugService } from "./debugService";
3
3
  /**
4
4
  * Retrieves information about the caller of the current function.
5
5
  *
@@ -16,16 +16,16 @@ function getCaller() {
16
16
  const err = new Error();
17
17
  const stack = err.stack || "";
18
18
  const stackLines = stack.split("\n").map((line) => line.trim());
19
- const ignoreFile = HttpDebugService.ignoreFile;
19
+ const ignoreFiles = DebugService.ignoreFiles;
20
20
  let callerIndex = 2;
21
21
  while (callerIndex < stackLines.length &&
22
22
  (stackLines[callerIndex].includes("node:internal") ||
23
23
  stackLines[callerIndex].includes("/node_modules/"))) {
24
24
  callerIndex++;
25
25
  }
26
- if (ignoreFile) {
26
+ if (ignoreFiles.length > 0) {
27
27
  while (callerIndex < stackLines.length &&
28
- stackLines[callerIndex].includes(ignoreFile)) {
28
+ ignoreFiles.some((ignoreFile) => stackLines[callerIndex].includes(ignoreFile))) {
29
29
  callerIndex++;
30
30
  }
31
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"schemaValidator.d.ts","sourceRoot":"","sources":["../../src/services/schemaValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiBjC,cAAM,eAAe,CAAC,CAAC,SAAS,OAAO;IAIzB,QAAQ,CAAC,MAAM,EAAE,CAAC;IAH9B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;gBAEE,MAAM,EAAE,CAAC;IAM9B,OAAO,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO;IAI3B,YAAY,CAAC,IAAI,EAAE,GAAG,GAAG,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAIzD,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAQ/B,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;CAoBtD;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"schemaValidator.d.ts","sourceRoot":"","sources":["../../src/services/schemaValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgBjC,cAAM,eAAe,CAAC,CAAC,SAAS,OAAO;IAIzB,QAAQ,CAAC,MAAM,EAAE,CAAC;IAH9B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;gBAEE,MAAM,EAAE,CAAC;IAM9B,OAAO,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO;IAI3B,YAAY,CAAC,IAAI,EAAE,GAAG,GAAG,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAIzD,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAQ/B,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;CAgBtD;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -3,7 +3,6 @@ import { ServerError } from "../http/badResponses/serverError";
3
3
  import { UnprocessableEntity } from "../http/badResponses/unprocessableEntity";
4
4
  import { formParse } from "./formParse";
5
5
  import { getCaller } from "./getCaller";
6
- import { httpDebug } from "./httpDebug";
7
6
  function formatErrorMessage(error) {
8
7
  const title = "Error validating:";
9
8
  const lines = error.issues.map(({ path, message }) => `-> ${path.join(".")}: ${message}`);
@@ -36,14 +35,13 @@ class SchemaValidator {
36
35
  formValidate(data, message) {
37
36
  const formParsed = formParse([data, this.schema]);
38
37
  if (!formParsed.success) {
39
- httpDebug("UnprocessableEntity", formParsed);
40
38
  const firstErrorKey = Object.keys(formParsed.fieldErrors)[0];
41
39
  throw new UnprocessableEntity({
42
40
  fields: formParsed.fields,
43
41
  fieldErrors: formParsed.fieldErrors,
44
42
  data: { scrollTo: firstErrorKey },
45
43
  message,
46
- }, false);
44
+ });
47
45
  }
48
46
  return formParsed.data;
49
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/server",
3
- "version": "3.0.1-beta.61",
3
+ "version": "3.0.1-beta.63",
4
4
  "author": "Arkyn | Lucas Gonçalves",
5
5
  "main": "./dist/bundle.js",
6
6
  "module": "./dist/bundle.js",