@arkyn/server 3.0.1-beta.116 → 3.0.1-beta.118

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 (178) hide show
  1. package/dist/bundle.js +721 -734
  2. package/dist/bundle.umd.cjs +5 -10
  3. package/dist/{api/arkynLogRequest.d.ts → http/api/_logRequest.d.ts} +22 -19
  4. package/dist/{api/arkynLogRequest.d.ts.map → http/api/_logRequest.d.ts.map} +1 -1
  5. package/dist/{api/arkynLogRequest.js → http/api/_logRequest.js} +30 -30
  6. package/dist/http/api/_makeRequest.d.ts +61 -0
  7. package/dist/http/api/_makeRequest.d.ts.map +1 -0
  8. package/dist/{api/makeRequest.js → http/api/_makeRequest.js} +29 -20
  9. package/dist/http/api/deleteRequest.d.ts +17 -0
  10. package/dist/http/api/deleteRequest.d.ts.map +1 -0
  11. package/dist/http/api/deleteRequest.js +18 -0
  12. package/dist/http/api/getRequest.d.ts +16 -0
  13. package/dist/http/api/getRequest.d.ts.map +1 -0
  14. package/dist/http/api/getRequest.js +17 -0
  15. package/dist/http/api/patchRequest.d.ts +17 -0
  16. package/dist/http/api/patchRequest.d.ts.map +1 -0
  17. package/dist/http/api/patchRequest.js +18 -0
  18. package/dist/http/api/postRequest.d.ts +17 -0
  19. package/dist/http/api/postRequest.d.ts.map +1 -0
  20. package/dist/http/api/postRequest.js +18 -0
  21. package/dist/http/api/putRequest.d.ts +17 -0
  22. package/dist/http/api/putRequest.d.ts.map +1 -0
  23. package/dist/http/api/putRequest.js +18 -0
  24. package/dist/http/badResponses/_badResponse.d.ts +18 -7
  25. package/dist/http/badResponses/_badResponse.d.ts.map +1 -1
  26. package/dist/http/badResponses/_badResponse.js +44 -13
  27. package/dist/http/badResponses/badGateway.d.ts +4 -8
  28. package/dist/http/badResponses/badGateway.d.ts.map +1 -1
  29. package/dist/http/badResponses/badGateway.js +9 -17
  30. package/dist/http/badResponses/badRequest.d.ts +4 -8
  31. package/dist/http/badResponses/badRequest.d.ts.map +1 -1
  32. package/dist/http/badResponses/badRequest.js +9 -17
  33. package/dist/http/badResponses/conflict.d.ts +4 -8
  34. package/dist/http/badResponses/conflict.d.ts.map +1 -1
  35. package/dist/http/badResponses/conflict.js +9 -17
  36. package/dist/http/badResponses/forbidden.d.ts +4 -8
  37. package/dist/http/badResponses/forbidden.d.ts.map +1 -1
  38. package/dist/http/badResponses/forbidden.js +9 -17
  39. package/dist/http/badResponses/notFound.d.ts +4 -8
  40. package/dist/http/badResponses/notFound.d.ts.map +1 -1
  41. package/dist/http/badResponses/notFound.js +9 -17
  42. package/dist/http/badResponses/notImplemented.d.ts +4 -8
  43. package/dist/http/badResponses/notImplemented.d.ts.map +1 -1
  44. package/dist/http/badResponses/notImplemented.js +9 -17
  45. package/dist/http/badResponses/serverError.d.ts +4 -8
  46. package/dist/http/badResponses/serverError.d.ts.map +1 -1
  47. package/dist/http/badResponses/serverError.js +9 -17
  48. package/dist/http/badResponses/unauthorized.d.ts +2 -6
  49. package/dist/http/badResponses/unauthorized.d.ts.map +1 -1
  50. package/dist/http/badResponses/unauthorized.js +7 -15
  51. package/dist/http/badResponses/unprocessableEntity.d.ts +13 -18
  52. package/dist/http/badResponses/unprocessableEntity.d.ts.map +1 -1
  53. package/dist/http/badResponses/unprocessableEntity.js +14 -22
  54. package/dist/http/successResponses/_successResponse.d.ts +18 -7
  55. package/dist/http/successResponses/_successResponse.d.ts.map +1 -1
  56. package/dist/http/successResponses/_successResponse.js +50 -21
  57. package/dist/http/successResponses/created.d.ts +8 -22
  58. package/dist/http/successResponses/created.d.ts.map +1 -1
  59. package/dist/http/successResponses/created.js +13 -25
  60. package/dist/http/successResponses/found.d.ts +9 -26
  61. package/dist/http/successResponses/found.d.ts.map +1 -1
  62. package/dist/http/successResponses/found.js +14 -29
  63. package/dist/http/successResponses/noContent.d.ts +4 -12
  64. package/dist/http/successResponses/noContent.d.ts.map +1 -1
  65. package/dist/http/successResponses/noContent.js +9 -17
  66. package/dist/http/successResponses/success.d.ts +8 -22
  67. package/dist/http/successResponses/success.d.ts.map +1 -1
  68. package/dist/http/successResponses/success.js +13 -25
  69. package/dist/http/successResponses/updated.d.ts +8 -22
  70. package/dist/http/successResponses/updated.d.ts.map +1 -1
  71. package/dist/http/successResponses/updated.js +13 -25
  72. package/dist/index.d.ts +9 -10
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +11 -12
  75. package/dist/services/apiService.d.ts +7 -28
  76. package/dist/services/apiService.d.ts.map +1 -1
  77. package/dist/services/apiService.js +35 -41
  78. package/dist/services/debugService.d.ts +16 -1
  79. package/dist/services/debugService.d.ts.map +1 -1
  80. package/dist/services/debugService.js +58 -1
  81. package/dist/services/logMapperService.d.ts +86 -0
  82. package/dist/services/logMapperService.d.ts.map +1 -0
  83. package/dist/services/logMapperService.js +68 -0
  84. package/dist/services/logService.d.ts +38 -0
  85. package/dist/services/logService.d.ts.map +1 -0
  86. package/dist/services/logService.js +40 -0
  87. package/dist/{services → utilities}/decodeRequestBody.d.ts +3 -4
  88. package/dist/utilities/decodeRequestBody.d.ts.map +1 -0
  89. package/dist/{services → utilities}/decodeRequestBody.js +5 -5
  90. package/dist/{services/decodeErrorMessageFromRequest.d.ts → utilities/decodeRequestErrorMessage.d.ts} +6 -6
  91. package/dist/utilities/decodeRequestErrorMessage.d.ts.map +1 -0
  92. package/dist/{services/decodeErrorMessageFromRequest.js → utilities/decodeRequestErrorMessage.js} +5 -5
  93. package/dist/utilities/errorHandler.d.ts +50 -0
  94. package/dist/utilities/errorHandler.d.ts.map +1 -0
  95. package/dist/{services → utilities}/errorHandler.js +34 -28
  96. package/dist/utilities/flushDebugLogs.d.ts +46 -0
  97. package/dist/utilities/flushDebugLogs.d.ts.map +1 -0
  98. package/dist/utilities/flushDebugLogs.js +59 -0
  99. package/dist/{services → utilities}/formAsyncParse.d.ts +3 -3
  100. package/dist/utilities/formAsyncParse.d.ts.map +1 -0
  101. package/dist/{services → utilities}/formAsyncParse.js +3 -3
  102. package/dist/{services → utilities}/formParse.d.ts +3 -3
  103. package/dist/utilities/formParse.d.ts.map +1 -0
  104. package/dist/{services → utilities}/formParse.js +3 -3
  105. package/dist/{services → utilities}/getScopedParams.d.ts +3 -4
  106. package/dist/utilities/getScopedParams.d.ts.map +1 -0
  107. package/dist/{services → utilities}/getScopedParams.js +4 -4
  108. package/dist/{services → utilities}/schemaValidator.d.ts +3 -15
  109. package/dist/utilities/schemaValidator.d.ts.map +1 -0
  110. package/dist/{services → utilities}/schemaValidator.js +3 -19
  111. package/dist/validations/validateCep.d.ts +7 -12
  112. package/dist/validations/validateCep.d.ts.map +1 -1
  113. package/dist/validations/validateCep.js +9 -15
  114. package/dist/validations/validateCnpj.d.ts +4 -5
  115. package/dist/validations/validateCnpj.d.ts.map +1 -1
  116. package/dist/validations/validateCnpj.js +12 -5
  117. package/dist/validations/validateCpf.d.ts +3 -4
  118. package/dist/validations/validateCpf.d.ts.map +1 -1
  119. package/dist/validations/validateCpf.js +11 -4
  120. package/dist/validations/validateDate.d.ts +16 -23
  121. package/dist/validations/validateDate.d.ts.map +1 -1
  122. package/dist/validations/validateDate.js +38 -56
  123. package/dist/validations/validateEmail.d.ts +3 -4
  124. package/dist/validations/validateEmail.d.ts.map +1 -1
  125. package/dist/validations/validateEmail.js +23 -35
  126. package/dist/validations/validatePassword.d.ts +3 -4
  127. package/dist/validations/validatePassword.d.ts.map +1 -1
  128. package/dist/validations/validatePassword.js +5 -5
  129. package/dist/validations/validatePhone.d.ts +3 -4
  130. package/dist/validations/validatePhone.d.ts.map +1 -1
  131. package/dist/validations/validatePhone.js +4 -4
  132. package/dist/validations/validateRg.d.ts +3 -4
  133. package/dist/validations/validateRg.d.ts.map +1 -1
  134. package/dist/validations/validateRg.js +4 -4
  135. package/package.json +1 -1
  136. package/dist/api/deleteRequest.d.ts +0 -13
  137. package/dist/api/deleteRequest.d.ts.map +0 -1
  138. package/dist/api/deleteRequest.js +0 -14
  139. package/dist/api/getRequest.d.ts +0 -12
  140. package/dist/api/getRequest.d.ts.map +0 -1
  141. package/dist/api/getRequest.js +0 -13
  142. package/dist/api/makeRequest.d.ts +0 -38
  143. package/dist/api/makeRequest.d.ts.map +0 -1
  144. package/dist/api/patchRequest.d.ts +0 -13
  145. package/dist/api/patchRequest.d.ts.map +0 -1
  146. package/dist/api/patchRequest.js +0 -14
  147. package/dist/api/postRequest.d.ts +0 -13
  148. package/dist/api/postRequest.d.ts.map +0 -1
  149. package/dist/api/postRequest.js +0 -14
  150. package/dist/api/putRequest.d.ts +0 -13
  151. package/dist/api/putRequest.d.ts.map +0 -1
  152. package/dist/api/putRequest.js +0 -14
  153. package/dist/mapper/arkynLogRequestMapper.d.ts +0 -30
  154. package/dist/mapper/arkynLogRequestMapper.d.ts.map +0 -1
  155. package/dist/mapper/arkynLogRequestMapper.js +0 -44
  156. package/dist/services/arkynLogService.d.ts +0 -44
  157. package/dist/services/arkynLogService.d.ts.map +0 -1
  158. package/dist/services/arkynLogService.js +0 -46
  159. package/dist/services/decodeErrorMessageFromRequest.d.ts.map +0 -1
  160. package/dist/services/decodeRequestBody.d.ts.map +0 -1
  161. package/dist/services/errorHandler.d.ts +0 -44
  162. package/dist/services/errorHandler.d.ts.map +0 -1
  163. package/dist/services/flushDebugLogs.d.ts +0 -8
  164. package/dist/services/flushDebugLogs.d.ts.map +0 -1
  165. package/dist/services/flushDebugLogs.js +0 -20
  166. package/dist/services/formAsyncParse.d.ts.map +0 -1
  167. package/dist/services/formParse.d.ts.map +0 -1
  168. package/dist/services/getCaller.d.ts +0 -17
  169. package/dist/services/getCaller.d.ts.map +0 -1
  170. package/dist/services/getCaller.js +0 -60
  171. package/dist/services/getScopedParams.d.ts.map +0 -1
  172. package/dist/services/measureRouteExecution.d.ts +0 -3
  173. package/dist/services/measureRouteExecution.d.ts.map +0 -1
  174. package/dist/services/measureRouteExecution.js +0 -24
  175. package/dist/services/schemaValidator.d.ts.map +0 -1
  176. package/dist/types/ApiResponseDTO.d.ts +0 -17
  177. package/dist/types/ApiResponseDTO.d.ts.map +0 -1
  178. package/dist/types/ApiResponseDTO.js +0 -1
@@ -0,0 +1,18 @@
1
+ import { makeRequest } from "./_makeRequest";
2
+ /**
3
+ * Sends a POST request to the specified URL with optional headers and body.
4
+ *
5
+ * @template T - The expected type of the response data.
6
+ * @param {InputProps} input - The options for the POST request, including URL, URL parameters, headers, and body.
7
+ * @returns {Promise<ApiResponseDTO<T>>} A promise that resolves to the API response.
8
+ */
9
+ async function postRequest(input) {
10
+ return makeRequest({
11
+ method: "POST",
12
+ url: input.url,
13
+ urlParams: input.urlParams,
14
+ headers: input.headers,
15
+ body: input.body,
16
+ });
17
+ }
18
+ export { postRequest };
@@ -0,0 +1,17 @@
1
+ import { type ApiResponseDTO } from "./_makeRequest";
2
+ type InputProps = {
3
+ url: string;
4
+ urlParams?: Record<string, string>;
5
+ headers?: HeadersInit;
6
+ body?: any;
7
+ };
8
+ /**
9
+ * Sends a PUT request to the specified URL with optional headers and body.
10
+ *
11
+ * @template T - The expected type of the response data.
12
+ * @param {InputProps} input - The options for the PUT request, including URL, URL parameters, headers, and body.
13
+ * @returns {Promise<ApiResponseDTO<T>>} A promise that resolves to the API response.
14
+ */
15
+ declare function putRequest<T = any>(input: InputProps): Promise<ApiResponseDTO<T>>;
16
+ export { putRequest };
17
+ //# sourceMappingURL=putRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"putRequest.d.ts","sourceRoot":"","sources":["../../../src/http/api/putRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAElE,KAAK,UAAU,GAAG;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ,CAAC;AAEF;;;;;;GAMG;AAEH,iBAAe,UAAU,CAAC,CAAC,GAAG,GAAG,EAC/B,KAAK,EAAE,UAAU,GAChB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAQ5B;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { makeRequest } from "./_makeRequest";
2
+ /**
3
+ * Sends a PUT request to the specified URL with optional headers and body.
4
+ *
5
+ * @template T - The expected type of the response data.
6
+ * @param {InputProps} input - The options for the PUT request, including URL, URL parameters, headers, and body.
7
+ * @returns {Promise<ApiResponseDTO<T>>} A promise that resolves to the API response.
8
+ */
9
+ async function putRequest(input) {
10
+ return makeRequest({
11
+ method: "PUT",
12
+ url: input.url,
13
+ urlParams: input.urlParams,
14
+ headers: input.headers,
15
+ body: input.body,
16
+ });
17
+ }
18
+ export { putRequest };
@@ -1,11 +1,22 @@
1
- type Input = {
2
- name: string;
3
- body?: any;
4
- cause?: any;
5
- message?: string;
6
- };
7
1
  declare class BadResponse {
8
- onDebug(input: Input): void;
2
+ private _cause?;
3
+ private _name;
4
+ private _status;
5
+ private _statusText;
6
+ get cause(): any;
7
+ set cause(value: any);
8
+ get name(): string;
9
+ set name(value: string);
10
+ get status(): number;
11
+ set status(value: number);
12
+ get statusText(): string;
13
+ set statusText(value: string);
14
+ onDebug(): void;
15
+ makeBody(): {
16
+ name: string;
17
+ message: string;
18
+ cause: any;
19
+ };
9
20
  }
10
21
  export { BadResponse };
11
22
  //# sourceMappingURL=_badResponse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"_badResponse.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/_badResponse.ts"],"names":[],"mappings":"AAGA,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,cAAM,WAAW;IACf,OAAO,CAAC,KAAK,EAAE,KAAK;CAgBrB;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"_badResponse.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/_badResponse.ts"],"names":[],"mappings":"AAGA,cAAM,WAAW;IACf,OAAO,CAAC,MAAM,CAAC,CAAM;IACrB,OAAO,CAAC,KAAK,CAAyB;IACtC,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,WAAW,CAA2B;IAE9C,IAAI,KAAK,IAAI,GAAG,CAEf;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,GAAG,EAEnB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,EAErB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,EAEvB;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,IAAI,UAAU,CAAC,KAAK,EAAE,MAAM,EAE3B;IAED,OAAO;IAaP,QAAQ;;;;;CAOT;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -1,20 +1,51 @@
1
- import { flushDebugLogs } from "../../services/flushDebugLogs";
2
- import { getCaller } from "../../services/getCaller";
1
+ import { DebugService } from "../../services/debugService";
2
+ import { flushDebugLogs } from "../../utilities/flushDebugLogs";
3
3
  class BadResponse {
4
- onDebug(input) {
5
- const { name, body, cause, message } = input;
4
+ _cause;
5
+ _name = "BadResponse";
6
+ _status = 500;
7
+ _statusText = "Unknown error";
8
+ get cause() {
9
+ return this._cause;
10
+ }
11
+ set cause(value) {
12
+ this._cause = value;
13
+ }
14
+ get name() {
15
+ return this._name;
16
+ }
17
+ set name(value) {
18
+ this._name = value;
19
+ }
20
+ get status() {
21
+ return this._status;
22
+ }
23
+ set status(value) {
24
+ this._status = value;
25
+ }
26
+ get statusText() {
27
+ return this._statusText;
28
+ }
29
+ set statusText(value) {
30
+ this._statusText = value;
31
+ }
32
+ onDebug() {
6
33
  const debugs = [];
7
- const { callerInfo, functionName } = getCaller();
8
- debugs.push(`${name} initialized`);
34
+ const { callerInfo, functionName } = DebugService.getCaller();
9
35
  debugs.push(`Caller Function: ${functionName}`);
10
36
  debugs.push(`Caller Location: ${callerInfo}`);
11
- if (message)
12
- debugs.push(`Message: ${message}`);
13
- if (body)
14
- debugs.push(`Body: ${JSON.stringify(body, null, 2)}`);
15
- if (cause)
16
- debugs.push(`Cause: ${JSON.stringify(cause, null, 2)}`);
17
- flushDebugLogs({ scheme: "red", name: "ARKYN-BAD-RESPONSE-DEBUG", debugs });
37
+ if (this._statusText)
38
+ debugs.push(`Message: ${this._statusText}`);
39
+ if (this._cause)
40
+ debugs.push(`Cause: ${JSON.stringify(this._cause)}`);
41
+ flushDebugLogs({ scheme: "red", name: this._name, debugs });
42
+ }
43
+ makeBody() {
44
+ return {
45
+ name: this._name,
46
+ message: this._statusText,
47
+ cause: this._cause,
48
+ };
18
49
  }
19
50
  }
20
51
  export { BadResponse };
@@ -5,29 +5,25 @@ import { BadResponse } from "./_badResponse";
5
5
  * including the response body, headers, status, and status text.
6
6
  */
7
7
  declare class BadGateway extends BadResponse {
8
- body: any;
9
- cause?: any;
10
- status: number;
11
- statusText: string;
12
8
  /**
13
9
  * Creates an instance of the `BadGateway` class.
14
10
  *
15
- * @param message - A descriptive message explaining the cause of the error.
16
- * @param cause - Optional additional information about the cause of the error.
11
+ * @param {string} message - A descriptive message explaining the cause of the error.
12
+ * @param {any} cause - Optional additional information about the cause of the error.
17
13
  */
18
14
  constructor(message: string, cause?: any);
19
15
  /**
20
16
  * Converts the `BadGateway` instance into a `Response` object with a JSON body.
21
17
  * This method ensures the response has the appropriate headers, status, and status text.
22
18
  *
23
- * @returns A `Response` object with the serialized JSON body and response metadata.
19
+ * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
24
20
  */
25
21
  toResponse(): Response;
26
22
  /**
27
23
  * Converts the `BadGateway` instance into a `Response` object using the `Response.json` method.
28
24
  * This method is an alternative to `toResponse` for generating JSON error responses.
29
25
  *
30
- * @returns A `Response` object with the JSON body and response metadata.
26
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
31
27
  */
32
28
  toJson(): Response;
33
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"badGateway.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/badGateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,UAAW,SAAQ,WAAW;IAClC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAexC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"badGateway.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/badGateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,UAAW,SAAQ,WAAW;IAClC;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAWxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -5,33 +5,25 @@ import { BadResponse } from "./_badResponse";
5
5
  * including the response body, headers, status, and status text.
6
6
  */
7
7
  class BadGateway extends BadResponse {
8
- body;
9
- cause;
10
- status = 502;
11
- statusText;
12
8
  /**
13
9
  * Creates an instance of the `BadGateway` class.
14
10
  *
15
- * @param message - A descriptive message explaining the cause of the error.
16
- * @param cause - Optional additional information about the cause of the error.
11
+ * @param {string} message - A descriptive message explaining the cause of the error.
12
+ * @param {any} cause - Optional additional information about the cause of the error.
17
13
  */
18
14
  constructor(message, cause) {
19
15
  super();
20
- this.body = { name: "BadGateway", message: message };
16
+ this.name = "BadGateway";
17
+ this.status = 502;
21
18
  this.statusText = message;
22
19
  this.cause = cause ? JSON.stringify(cause) : undefined;
23
- this.onDebug({
24
- name: "BadGateway",
25
- body: this.body,
26
- cause: this.cause,
27
- message: this.statusText,
28
- });
20
+ this.onDebug();
29
21
  }
30
22
  /**
31
23
  * Converts the `BadGateway` instance into a `Response` object with a JSON body.
32
24
  * This method ensures the response has the appropriate headers, status, and status text.
33
25
  *
34
- * @returns A `Response` object with the serialized JSON body and response metadata.
26
+ * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
35
27
  */
36
28
  toResponse() {
37
29
  const responseInit = {
@@ -39,20 +31,20 @@ class BadGateway extends BadResponse {
39
31
  status: this.status,
40
32
  statusText: this.statusText,
41
33
  };
42
- return new Response(JSON.stringify(this.body), responseInit);
34
+ return new Response(JSON.stringify(this.makeBody()), responseInit);
43
35
  }
44
36
  /**
45
37
  * Converts the `BadGateway` instance into a `Response` object using the `Response.json` method.
46
38
  * This method is an alternative to `toResponse` for generating JSON error responses.
47
39
  *
48
- * @returns A `Response` object with the JSON body and response metadata.
40
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
49
41
  */
50
42
  toJson() {
51
43
  const responseInit = {
52
44
  status: this.status,
53
45
  statusText: this.statusText,
54
46
  };
55
- return Response.json(this.body, responseInit);
47
+ return Response.json(this.makeBody(), responseInit);
56
48
  }
57
49
  }
58
50
  export { BadGateway };
@@ -5,29 +5,25 @@ import { BadResponse } from "./_badResponse";
5
5
  * including the response body, headers, status, and status text.
6
6
  */
7
7
  declare class BadRequest extends BadResponse {
8
- body: any;
9
- cause?: any;
10
- status: number;
11
- statusText: string;
12
8
  /**
13
9
  * Creates an instance of the `BadRequest` class.
14
10
  *
15
- * @param message - A descriptive message explaining the cause of the error.
16
- * @param cause - Optional additional information about the cause of the error.
11
+ * @param {string} message - A descriptive message explaining the cause of the error.
12
+ * @param {any} cause - Optional additional information about the cause of the error.
17
13
  */
18
14
  constructor(message: string, cause?: any);
19
15
  /**
20
16
  * Converts the `BadRequest` instance into a `Response` object with a JSON body.
21
17
  * This method ensures the response has the appropriate headers, status, and status text.
22
18
  *
23
- * @returns A `Response` object with the serialized JSON body and response metadata.
19
+ * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
24
20
  */
25
21
  toResponse(): Response;
26
22
  /**
27
23
  * Converts the `BadRequest` instance into a `Response` object using the `Response.json` method.
28
24
  * This method is an alternative to `toResponse` for generating JSON error responses.
29
25
  *
30
- * @returns A `Response` object with the JSON body and response metadata.
26
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
31
27
  */
32
28
  toJson(): Response;
33
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"badRequest.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/badRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,UAAW,SAAQ,WAAW;IAClC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAexC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"badRequest.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/badRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,UAAW,SAAQ,WAAW;IAClC;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAWxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -5,33 +5,25 @@ import { BadResponse } from "./_badResponse";
5
5
  * including the response body, headers, status, and status text.
6
6
  */
7
7
  class BadRequest extends BadResponse {
8
- body;
9
- cause;
10
- status = 400;
11
- statusText;
12
8
  /**
13
9
  * Creates an instance of the `BadRequest` class.
14
10
  *
15
- * @param message - A descriptive message explaining the cause of the error.
16
- * @param cause - Optional additional information about the cause of the error.
11
+ * @param {string} message - A descriptive message explaining the cause of the error.
12
+ * @param {any} cause - Optional additional information about the cause of the error.
17
13
  */
18
14
  constructor(message, cause) {
19
15
  super();
20
- this.body = { name: "BadRequest", message: message };
16
+ this.name = "BadRequest";
17
+ this.status = 400;
21
18
  this.statusText = message;
22
19
  this.cause = cause ? JSON.stringify(cause) : undefined;
23
- this.onDebug({
24
- name: "BadRequest",
25
- body: this.body,
26
- cause: this.cause,
27
- message: this.statusText,
28
- });
20
+ this.onDebug();
29
21
  }
30
22
  /**
31
23
  * Converts the `BadRequest` instance into a `Response` object with a JSON body.
32
24
  * This method ensures the response has the appropriate headers, status, and status text.
33
25
  *
34
- * @returns A `Response` object with the serialized JSON body and response metadata.
26
+ * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
35
27
  */
36
28
  toResponse() {
37
29
  const responseInit = {
@@ -39,20 +31,20 @@ class BadRequest extends BadResponse {
39
31
  status: this.status,
40
32
  statusText: this.statusText,
41
33
  };
42
- return new Response(JSON.stringify(this.body), responseInit);
34
+ return new Response(JSON.stringify(this.makeBody()), responseInit);
43
35
  }
44
36
  /**
45
37
  * Converts the `BadRequest` instance into a `Response` object using the `Response.json` method.
46
38
  * This method is an alternative to `toResponse` for generating JSON error responses.
47
39
  *
48
- * @returns A `Response` object with the JSON body and response metadata.
40
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
49
41
  */
50
42
  toJson() {
51
43
  const responseInit = {
52
44
  status: this.status,
53
45
  statusText: this.statusText,
54
46
  };
55
- return Response.json(this.body, responseInit);
47
+ return Response.json(this.makeBody(), responseInit);
56
48
  }
57
49
  }
58
50
  export { BadRequest };
@@ -5,29 +5,25 @@ import { BadResponse } from "./_badResponse";
5
5
  * including the response body, headers, status, and status text.
6
6
  */
7
7
  declare class Conflict extends BadResponse {
8
- body: any;
9
- cause?: any;
10
- status: number;
11
- statusText: string;
12
8
  /**
13
9
  * Creates an instance of the `Conflict` class.
14
10
  *
15
- * @param message - A descriptive message explaining the cause of the conflict.
16
- * @param cause - Optional additional information about the cause of the conflict.
11
+ * @param {string} message - A descriptive message explaining the cause of the conflict.
12
+ * @param {any} cause - Optional additional information about the cause of the conflict.
17
13
  */
18
14
  constructor(message: string, cause?: any);
19
15
  /**
20
16
  * Converts the `Conflict` instance into a `Response` object with a JSON body.
21
17
  * This method ensures the response has the appropriate headers, status, and status text.
22
18
  *
23
- * @returns A `Response` object with the serialized JSON body and response metadata.
19
+ * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
24
20
  */
25
21
  toResponse(): Response;
26
22
  /**
27
23
  * Converts the `Conflict` instance into a `Response` object using the `Response.json` method.
28
24
  * This method is an alternative to `toResponse` for generating JSON error responses.
29
25
  *
30
- * @returns A `Response` object with the JSON body and response metadata.
26
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
31
27
  */
32
28
  toJson(): Response;
33
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"conflict.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/conflict.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,QAAS,SAAQ,WAAW;IAChC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAexC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"conflict.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/conflict.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,QAAS,SAAQ,WAAW;IAChC;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAWxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -5,33 +5,25 @@ import { BadResponse } from "./_badResponse";
5
5
  * including the response body, headers, status, and status text.
6
6
  */
7
7
  class Conflict extends BadResponse {
8
- body;
9
- cause;
10
- status = 409;
11
- statusText;
12
8
  /**
13
9
  * Creates an instance of the `Conflict` class.
14
10
  *
15
- * @param message - A descriptive message explaining the cause of the conflict.
16
- * @param cause - Optional additional information about the cause of the conflict.
11
+ * @param {string} message - A descriptive message explaining the cause of the conflict.
12
+ * @param {any} cause - Optional additional information about the cause of the conflict.
17
13
  */
18
14
  constructor(message, cause) {
19
15
  super();
20
- this.body = { name: "Conflict", message: message };
16
+ this.name = "Conflict";
17
+ this.status = 409;
21
18
  this.statusText = message;
22
19
  this.cause = cause ? JSON.stringify(cause) : undefined;
23
- this.onDebug({
24
- name: "Conflict",
25
- body: this.body,
26
- cause: this.cause,
27
- message: this.statusText,
28
- });
20
+ this.onDebug();
29
21
  }
30
22
  /**
31
23
  * Converts the `Conflict` instance into a `Response` object with a JSON body.
32
24
  * This method ensures the response has the appropriate headers, status, and status text.
33
25
  *
34
- * @returns A `Response` object with the serialized JSON body and response metadata.
26
+ * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
35
27
  */
36
28
  toResponse() {
37
29
  const responseInit = {
@@ -39,20 +31,20 @@ class Conflict extends BadResponse {
39
31
  status: this.status,
40
32
  statusText: this.statusText,
41
33
  };
42
- return new Response(JSON.stringify(this.body), responseInit);
34
+ return new Response(JSON.stringify(this.makeBody()), responseInit);
43
35
  }
44
36
  /**
45
37
  * Converts the `Conflict` instance into a `Response` object using the `Response.json` method.
46
38
  * This method is an alternative to `toResponse` for generating JSON error responses.
47
39
  *
48
- * @returns A `Response` object with the JSON body and response metadata.
40
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
49
41
  */
50
42
  toJson() {
51
43
  const responseInit = {
52
44
  status: this.status,
53
45
  statusText: this.statusText,
54
46
  };
55
- return Response.json(this.body, responseInit);
47
+ return Response.json(this.makeBody(), responseInit);
56
48
  }
57
49
  }
58
50
  export { Conflict };
@@ -5,29 +5,25 @@ import { BadResponse } from "./_badResponse";
5
5
  * including the response body, headers, status, and status text.
6
6
  */
7
7
  declare class Forbidden extends BadResponse {
8
- body: any;
9
- cause?: any;
10
- status: number;
11
- statusText: string;
12
8
  /**
13
9
  * Creates an instance of the `Forbidden` class.
14
10
  *
15
- * @param message - A descriptive message explaining why access is forbidden.
16
- * @param cause - Optional additional information about the cause of the error.
11
+ * @param {string} message - A descriptive message explaining why access is forbidden.
12
+ * @param {any} cause - Optional additional information about the cause of the error.
17
13
  */
18
14
  constructor(message: string, cause?: any);
19
15
  /**
20
16
  * Converts the `Forbidden` instance into a `Response` object with a JSON body.
21
17
  * This method ensures the response has the appropriate headers, status, and status text.
22
18
  *
23
- * @returns A `Response` object with the serialized JSON body and response metadata.
19
+ * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
24
20
  */
25
21
  toResponse(): Response;
26
22
  /**
27
23
  * Converts the `Forbidden` instance into a `Response` object using the `Response.json` method.
28
24
  * This method is an alternative to `toResponse` for generating JSON error responses.
29
25
  *
30
- * @returns A `Response` object with the JSON body and response metadata.
26
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
31
27
  */
32
28
  toJson(): Response;
33
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"forbidden.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/forbidden.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,SAAU,SAAQ,WAAW;IACjC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAexC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"forbidden.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/forbidden.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,SAAU,SAAQ,WAAW;IACjC;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAWxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -5,33 +5,25 @@ import { BadResponse } from "./_badResponse";
5
5
  * including the response body, headers, status, and status text.
6
6
  */
7
7
  class Forbidden extends BadResponse {
8
- body;
9
- cause;
10
- status = 403;
11
- statusText;
12
8
  /**
13
9
  * Creates an instance of the `Forbidden` class.
14
10
  *
15
- * @param message - A descriptive message explaining why access is forbidden.
16
- * @param cause - Optional additional information about the cause of the error.
11
+ * @param {string} message - A descriptive message explaining why access is forbidden.
12
+ * @param {any} cause - Optional additional information about the cause of the error.
17
13
  */
18
14
  constructor(message, cause) {
19
15
  super();
20
- this.body = { name: "Forbidden", message: message };
16
+ this.name = "Forbidden";
17
+ this.status = 403;
21
18
  this.statusText = message;
22
19
  this.cause = cause ? JSON.stringify(cause) : undefined;
23
- this.onDebug({
24
- name: "Forbidden",
25
- body: this.body,
26
- cause: this.cause,
27
- message: this.statusText,
28
- });
20
+ this.onDebug();
29
21
  }
30
22
  /**
31
23
  * Converts the `Forbidden` instance into a `Response` object with a JSON body.
32
24
  * This method ensures the response has the appropriate headers, status, and status text.
33
25
  *
34
- * @returns A `Response` object with the serialized JSON body and response metadata.
26
+ * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
35
27
  */
36
28
  toResponse() {
37
29
  const responseInit = {
@@ -39,20 +31,20 @@ class Forbidden extends BadResponse {
39
31
  status: this.status,
40
32
  statusText: this.statusText,
41
33
  };
42
- return new Response(JSON.stringify(this.body), responseInit);
34
+ return new Response(JSON.stringify(this.makeBody()), responseInit);
43
35
  }
44
36
  /**
45
37
  * Converts the `Forbidden` instance into a `Response` object using the `Response.json` method.
46
38
  * This method is an alternative to `toResponse` for generating JSON error responses.
47
39
  *
48
- * @returns A `Response` object with the JSON body and response metadata.
40
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
49
41
  */
50
42
  toJson() {
51
43
  const responseInit = {
52
44
  status: this.status,
53
45
  statusText: this.statusText,
54
46
  };
55
- return Response.json(this.body, responseInit);
47
+ return Response.json(this.makeBody(), responseInit);
56
48
  }
57
49
  }
58
50
  export { Forbidden };
@@ -5,29 +5,25 @@ import { BadResponse } from "./_badResponse";
5
5
  * including the response body, headers, status, and status text.
6
6
  */
7
7
  declare class NotFound extends BadResponse {
8
- body: any;
9
- cause?: any;
10
- status: number;
11
- statusText: string;
12
8
  /**
13
9
  * Creates an instance of the `NotFound` class.
14
10
  *
15
- * @param message - A descriptive message explaining the reason the resource was not found.
16
- * @param cause - Optional additional information about the cause of the error.
11
+ * @param {string} message - A descriptive message explaining the reason the resource was not found.
12
+ * @param {any} cause - Optional additional information about the cause of the error.
17
13
  */
18
14
  constructor(message: string, cause?: any);
19
15
  /**
20
16
  * Converts the `NotFound` instance into a `Response` object with a JSON body.
21
17
  * This method ensures the response has the appropriate headers, status, and status text.
22
18
  *
23
- * @returns A `Response` object with the serialized JSON body and response metadata.
19
+ * @returns {Response} A `Response` object with the serialized JSON body and response metadata.
24
20
  */
25
21
  toResponse(): Response;
26
22
  /**
27
23
  * Converts the `NotFound` instance into a `Response` object using the `Response.json` method.
28
24
  * This method is an alternative to `toResponse` for generating JSON error responses.
29
25
  *
30
- * @returns A `Response` object with the JSON body and response metadata.
26
+ * @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
31
27
  */
32
28
  toJson(): Response;
33
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"notFound.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/notFound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,QAAS,SAAQ,WAAW;IAChC,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAexC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"notFound.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/notFound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,QAAS,SAAQ,WAAW;IAChC;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAWxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}