@arkyn/server 3.0.1-beta.14 → 3.0.1-beta.140
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/README.md +368 -65
- package/dist/bundle.js +3247 -0
- package/dist/bundle.umd.cjs +9 -0
- package/dist/{api/arkynLogRequest.d.ts → http/api/_logRequest.d.ts} +22 -19
- package/dist/{api/arkynLogRequest.d.ts.map → http/api/_logRequest.d.ts.map} +1 -1
- package/dist/http/api/_logRequest.js +109 -0
- package/dist/http/api/_makeRequest.d.ts +61 -0
- package/dist/http/api/_makeRequest.d.ts.map +1 -0
- package/dist/{api/makeRequest.js → http/api/_makeRequest.js} +33 -20
- package/dist/http/api/deleteRequest.d.ts +17 -0
- package/dist/http/api/deleteRequest.d.ts.map +1 -0
- package/dist/http/api/deleteRequest.js +18 -0
- package/dist/http/api/getRequest.d.ts +16 -0
- package/dist/http/api/getRequest.d.ts.map +1 -0
- package/dist/http/api/getRequest.js +17 -0
- package/dist/http/api/patchRequest.d.ts +17 -0
- package/dist/http/api/patchRequest.d.ts.map +1 -0
- package/dist/http/api/patchRequest.js +18 -0
- package/dist/http/api/postRequest.d.ts +17 -0
- package/dist/http/api/postRequest.d.ts.map +1 -0
- package/dist/http/api/postRequest.js +18 -0
- package/dist/http/api/putRequest.d.ts +17 -0
- package/dist/http/api/putRequest.d.ts.map +1 -0
- package/dist/http/api/putRequest.js +18 -0
- package/dist/http/badResponses/_badResponse.d.ts +25 -0
- package/dist/http/badResponses/_badResponse.d.ts.map +1 -0
- package/dist/http/badResponses/_badResponse.js +62 -0
- package/dist/http/badResponses/badGateway.d.ts +6 -9
- package/dist/http/badResponses/badGateway.d.ts.map +1 -1
- package/dist/http/badResponses/badGateway.js +12 -14
- package/dist/http/badResponses/badRequest.d.ts +6 -9
- package/dist/http/badResponses/badRequest.d.ts.map +1 -1
- package/dist/http/badResponses/badRequest.js +12 -14
- package/dist/http/badResponses/conflict.d.ts +6 -9
- package/dist/http/badResponses/conflict.d.ts.map +1 -1
- package/dist/http/badResponses/conflict.js +13 -14
- package/dist/http/badResponses/forbidden.d.ts +6 -9
- package/dist/http/badResponses/forbidden.d.ts.map +1 -1
- package/dist/http/badResponses/forbidden.js +12 -14
- package/dist/http/badResponses/notFound.d.ts +6 -9
- package/dist/http/badResponses/notFound.d.ts.map +1 -1
- package/dist/http/badResponses/notFound.js +12 -14
- package/dist/http/badResponses/notImplemented.d.ts +6 -9
- package/dist/http/badResponses/notImplemented.d.ts.map +1 -1
- package/dist/http/badResponses/notImplemented.js +12 -14
- package/dist/http/badResponses/serverError.d.ts +6 -9
- package/dist/http/badResponses/serverError.d.ts.map +1 -1
- package/dist/http/badResponses/serverError.js +12 -14
- package/dist/http/badResponses/unauthorized.d.ts +4 -7
- package/dist/http/badResponses/unauthorized.d.ts.map +1 -1
- package/dist/http/badResponses/unauthorized.js +11 -12
- package/dist/http/badResponses/unprocessableEntity.d.ts +15 -19
- package/dist/http/badResponses/unprocessableEntity.d.ts.map +1 -1
- package/dist/http/badResponses/unprocessableEntity.js +19 -21
- package/dist/http/successResponses/_successResponse.d.ts +36 -0
- package/dist/http/successResponses/_successResponse.d.ts.map +1 -0
- package/dist/http/successResponses/_successResponse.js +75 -0
- package/dist/http/successResponses/created.d.ts +9 -19
- package/dist/http/successResponses/created.d.ts.map +1 -1
- package/dist/http/successResponses/created.js +16 -25
- package/dist/http/successResponses/found.d.ts +10 -23
- package/dist/http/successResponses/found.d.ts.map +1 -1
- package/dist/http/successResponses/found.js +17 -29
- package/dist/http/successResponses/noContent.d.ts +6 -13
- package/dist/http/successResponses/noContent.d.ts.map +1 -1
- package/dist/http/successResponses/noContent.js +12 -17
- package/dist/http/successResponses/success.d.ts +9 -19
- package/dist/http/successResponses/success.d.ts.map +1 -1
- package/dist/http/successResponses/success.js +16 -25
- package/dist/http/successResponses/updated.d.ts +9 -19
- package/dist/http/successResponses/updated.d.ts.map +1 -1
- package/dist/http/successResponses/updated.js +16 -25
- package/dist/index.d.ts +19 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -13
- package/dist/services/apiService.d.ts +63 -0
- package/dist/services/apiService.d.ts.map +1 -0
- package/dist/services/apiService.js +158 -0
- package/dist/services/debugService.d.ts +69 -0
- package/dist/services/debugService.d.ts.map +1 -0
- package/dist/services/debugService.js +114 -0
- package/dist/services/logMapperService.d.ts +86 -0
- package/dist/services/logMapperService.d.ts.map +1 -0
- package/dist/services/logMapperService.js +68 -0
- package/dist/services/logService.d.ts +38 -0
- package/dist/services/logService.d.ts.map +1 -0
- package/dist/services/logService.js +40 -0
- package/dist/{services → utilities}/decodeRequestBody.d.ts +3 -4
- package/dist/utilities/decodeRequestBody.d.ts.map +1 -0
- package/dist/{services → utilities}/decodeRequestBody.js +5 -5
- package/dist/{services/decodeErrorMessageFromRequest.d.ts → utilities/decodeRequestErrorMessage.d.ts} +6 -6
- package/dist/utilities/decodeRequestErrorMessage.d.ts.map +1 -0
- package/dist/{services/decodeErrorMessageFromRequest.js → utilities/decodeRequestErrorMessage.js} +9 -5
- package/dist/utilities/errorHandler.d.ts +50 -0
- package/dist/utilities/errorHandler.d.ts.map +1 -0
- package/dist/{services → utilities}/errorHandler.js +34 -28
- package/dist/utilities/flushDebugLogs.d.ts +46 -0
- package/dist/utilities/flushDebugLogs.d.ts.map +1 -0
- package/dist/utilities/flushDebugLogs.js +61 -0
- package/dist/utilities/formAsyncParse.d.ts +59 -0
- package/dist/utilities/formAsyncParse.d.ts.map +1 -0
- package/dist/utilities/formAsyncParse.js +58 -0
- package/dist/{services → utilities}/formParse.d.ts +3 -3
- package/dist/utilities/formParse.d.ts.map +1 -0
- package/dist/{services → utilities}/formParse.js +3 -4
- package/dist/{services → utilities}/getScopedParams.d.ts +3 -4
- package/dist/utilities/getScopedParams.d.ts.map +1 -0
- package/dist/{services → utilities}/getScopedParams.js +4 -4
- package/dist/utilities/schemaValidator.d.ts +146 -0
- package/dist/utilities/schemaValidator.d.ts.map +1 -0
- package/dist/utilities/schemaValidator.js +190 -0
- package/dist/validations/validateCep.d.ts +19 -0
- package/dist/validations/validateCep.d.ts.map +1 -0
- package/dist/validations/validateCep.js +27 -0
- package/dist/validations/validateCnpj.d.ts +21 -0
- package/dist/validations/validateCnpj.d.ts.map +1 -0
- package/dist/validations/validateCnpj.js +59 -0
- package/dist/validations/validateCpf.d.ts +23 -0
- package/dist/validations/validateCpf.d.ts.map +1 -0
- package/dist/validations/validateCpf.js +61 -0
- package/dist/validations/validateDate.d.ts +27 -0
- package/dist/validations/validateDate.d.ts.map +1 -0
- package/dist/validations/validateDate.js +55 -0
- package/dist/validations/validateEmail.d.ts +21 -0
- package/dist/validations/validateEmail.d.ts.map +1 -0
- package/dist/validations/validateEmail.js +111 -0
- package/dist/validations/validatePassword.d.ts +20 -0
- package/dist/validations/validatePassword.d.ts.map +1 -0
- package/dist/validations/validatePassword.js +34 -0
- package/dist/validations/validatePhone.d.ts +28 -0
- package/dist/validations/validatePhone.d.ts.map +1 -0
- package/dist/validations/validatePhone.js +40 -0
- package/dist/validations/validateRg.d.ts +21 -0
- package/dist/validations/validateRg.d.ts.map +1 -0
- package/dist/validations/validateRg.js +31 -0
- package/package.json +27 -12
- package/dist/api/arkynLogRequest.js +0 -82
- package/dist/api/deleteRequest.d.ts +0 -13
- package/dist/api/deleteRequest.d.ts.map +0 -1
- package/dist/api/deleteRequest.js +0 -14
- package/dist/api/getRequest.d.ts +0 -12
- package/dist/api/getRequest.d.ts.map +0 -1
- package/dist/api/getRequest.js +0 -13
- package/dist/api/makeRequest.d.ts +0 -38
- package/dist/api/makeRequest.d.ts.map +0 -1
- package/dist/api/patchRequest.d.ts +0 -13
- package/dist/api/patchRequest.d.ts.map +0 -1
- package/dist/api/patchRequest.js +0 -14
- package/dist/api/postRequest.d.ts +0 -13
- package/dist/api/postRequest.d.ts.map +0 -1
- package/dist/api/postRequest.js +0 -14
- package/dist/api/putRequest.d.ts +0 -13
- package/dist/api/putRequest.d.ts.map +0 -1
- package/dist/api/putRequest.js +0 -14
- package/dist/config/apiInstance.d.ts +0 -80
- package/dist/config/apiInstance.d.ts.map +0 -1
- package/dist/config/apiInstance.js +0 -111
- package/dist/config/arkynLogInstance.d.ts +0 -44
- package/dist/config/arkynLogInstance.d.ts.map +0 -1
- package/dist/config/arkynLogInstance.js +0 -49
- package/dist/mapper/arkynLogRequestMapper.d.ts +0 -30
- package/dist/mapper/arkynLogRequestMapper.d.ts.map +0 -1
- package/dist/mapper/arkynLogRequestMapper.js +0 -44
- package/dist/services/decodeErrorMessageFromRequest.d.ts.map +0 -1
- package/dist/services/decodeRequestBody.d.ts.map +0 -1
- package/dist/services/errorHandler.d.ts +0 -44
- package/dist/services/errorHandler.d.ts.map +0 -1
- package/dist/services/formParse.d.ts.map +0 -1
- package/dist/services/getCaller.d.ts +0 -17
- package/dist/services/getCaller.d.ts.map +0 -1
- package/dist/services/getCaller.js +0 -65
- package/dist/services/getScopedParams.d.ts.map +0 -1
- package/dist/services/httpDebug.d.ts +0 -35
- package/dist/services/httpDebug.d.ts.map +0 -1
- package/dist/services/httpDebug.js +0 -52
- package/dist/services/measureRouteExecution.d.ts +0 -3
- package/dist/services/measureRouteExecution.d.ts.map +0 -1
- package/dist/services/measureRouteExecution.js +0 -24
- package/dist/services/schemaValidator.d.ts +0 -13
- package/dist/services/schemaValidator.d.ts.map +0 -1
- package/dist/services/schemaValidator.js +0 -51
- package/dist/types/ApiResponseDTO.d.ts +0 -17
- package/dist/types/ApiResponseDTO.d.ts.map +0 -1
- package/dist/types/ApiResponseDTO.js +0 -1
- package/src/api/arkynLogRequest.ts +0 -118
- package/src/api/deleteRequest.ts +0 -22
- package/src/api/getRequest.ts +0 -20
- package/src/api/makeRequest.ts +0 -118
- package/src/api/patchRequest.ts +0 -22
- package/src/api/postRequest.ts +0 -22
- package/src/api/putRequest.ts +0 -22
- package/src/config/apiInstance.ts +0 -148
- package/src/config/arkynLogInstance.ts +0 -70
- package/src/http/badResponses/badGateway.ts +0 -63
- package/src/http/badResponses/badRequest.ts +0 -63
- package/src/http/badResponses/conflict.ts +0 -63
- package/src/http/badResponses/forbidden.ts +0 -63
- package/src/http/badResponses/notFound.ts +0 -63
- package/src/http/badResponses/notImplemented.ts +0 -63
- package/src/http/badResponses/serverError.ts +0 -63
- package/src/http/badResponses/unauthorized.ts +0 -63
- package/src/http/badResponses/unprocessableEntity.ts +0 -79
- package/src/http/successResponses/created.ts +0 -64
- package/src/http/successResponses/found.ts +0 -67
- package/src/http/successResponses/noContent.ts +0 -42
- package/src/http/successResponses/success.ts +0 -64
- package/src/http/successResponses/updated.ts +0 -64
- package/src/index.ts +0 -31
- package/src/mapper/arkynLogRequestMapper.ts +0 -73
- package/src/services/decodeErrorMessageFromRequest.ts +0 -36
- package/src/services/decodeRequestBody.ts +0 -43
- package/src/services/errorHandler.ts +0 -99
- package/src/services/formParse.ts +0 -86
- package/src/services/getCaller.ts +0 -82
- package/src/services/getScopedParams.ts +0 -43
- package/src/services/httpDebug.ts +0 -61
- package/src/services/measureRouteExecution.ts +0 -31
- package/src/services/schemaValidator.ts +0 -66
- package/src/types/ApiResponseDTO.ts +0 -19
- package/tsconfig.json +0 -21
- package/vitest.config.ts +0 -5
|
@@ -1,32 +1,29 @@
|
|
|
1
|
+
import { BadResponse } from "./_badResponse";
|
|
1
2
|
/**
|
|
2
3
|
* Represents an HTTP error response with a status code of 500 (Internal Server Error).
|
|
3
4
|
* This class is used to standardize the structure of a "Server Error" response,
|
|
4
5
|
* including the response body, headers, status, and status text.
|
|
5
6
|
*/
|
|
6
|
-
declare class ServerError {
|
|
7
|
-
body: any;
|
|
8
|
-
cause?: any;
|
|
9
|
-
status: number;
|
|
10
|
-
statusText: string;
|
|
7
|
+
declare class ServerError extends BadResponse {
|
|
11
8
|
/**
|
|
12
9
|
* Creates an instance of the `ServerError` class.
|
|
13
10
|
*
|
|
14
|
-
* @param message - A descriptive message explaining the cause of the server error.
|
|
15
|
-
* @param cause - Optional additional information about the cause of the error.
|
|
11
|
+
* @param {string} message - A descriptive message explaining the cause of the server error.
|
|
12
|
+
* @param {any} cause - Optional additional information about the cause of the error.
|
|
16
13
|
*/
|
|
17
14
|
constructor(message: string, cause?: any);
|
|
18
15
|
/**
|
|
19
16
|
* Converts the `ServerError` instance into a `Response` object with a JSON body.
|
|
20
17
|
* This method ensures the response has the appropriate headers, status, and status text.
|
|
21
18
|
*
|
|
22
|
-
* @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.
|
|
23
20
|
*/
|
|
24
21
|
toResponse(): Response;
|
|
25
22
|
/**
|
|
26
23
|
* Converts the `ServerError` instance into a `Response` object using the `Response.json` method.
|
|
27
24
|
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
28
25
|
*
|
|
29
|
-
* @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.
|
|
30
27
|
*/
|
|
31
28
|
toJson(): Response;
|
|
32
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverError.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/serverError.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serverError.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/serverError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,WAAY,SAAQ,WAAW;IACnC;;;;;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,WAAW,EAAE,CAAC"}
|
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BadResponse } from "./_badResponse";
|
|
2
2
|
/**
|
|
3
3
|
* Represents an HTTP error response with a status code of 500 (Internal Server Error).
|
|
4
4
|
* This class is used to standardize the structure of a "Server Error" response,
|
|
5
5
|
* including the response body, headers, status, and status text.
|
|
6
6
|
*/
|
|
7
|
-
class ServerError {
|
|
8
|
-
body;
|
|
9
|
-
cause;
|
|
10
|
-
status = 500;
|
|
11
|
-
statusText;
|
|
7
|
+
class ServerError extends BadResponse {
|
|
12
8
|
/**
|
|
13
9
|
* Creates an instance of the `ServerError` class.
|
|
14
10
|
*
|
|
15
|
-
* @param message - A descriptive message explaining the cause of the server 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 server error.
|
|
12
|
+
* @param {any} cause - Optional additional information about the cause of the error.
|
|
17
13
|
*/
|
|
18
14
|
constructor(message, cause) {
|
|
19
|
-
|
|
15
|
+
super();
|
|
16
|
+
this.name = "ServerError";
|
|
17
|
+
this.status = 500;
|
|
20
18
|
this.statusText = message;
|
|
21
19
|
this.cause = cause ? JSON.stringify(cause) : undefined;
|
|
22
|
-
|
|
20
|
+
this.onDebug();
|
|
23
21
|
}
|
|
24
22
|
/**
|
|
25
23
|
* Converts the `ServerError` instance into a `Response` object with a JSON body.
|
|
26
24
|
* This method ensures the response has the appropriate headers, status, and status text.
|
|
27
25
|
*
|
|
28
|
-
* @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.
|
|
29
27
|
*/
|
|
30
28
|
toResponse() {
|
|
31
29
|
const responseInit = {
|
|
@@ -33,20 +31,20 @@ class ServerError {
|
|
|
33
31
|
status: this.status,
|
|
34
32
|
statusText: this.statusText,
|
|
35
33
|
};
|
|
36
|
-
return new Response(JSON.stringify(this.
|
|
34
|
+
return new Response(JSON.stringify(this.makeBody()), responseInit);
|
|
37
35
|
}
|
|
38
36
|
/**
|
|
39
37
|
* Converts the `ServerError` instance into a `Response` object using the `Response.json` method.
|
|
40
38
|
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
41
39
|
*
|
|
42
|
-
* @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.
|
|
43
41
|
*/
|
|
44
42
|
toJson() {
|
|
45
43
|
const responseInit = {
|
|
46
44
|
status: this.status,
|
|
47
45
|
statusText: this.statusText,
|
|
48
46
|
};
|
|
49
|
-
return Response.json(this.
|
|
47
|
+
return Response.json(this.makeBody(), responseInit);
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
export { ServerError };
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
+
import { BadResponse } from "./_badResponse";
|
|
1
2
|
/**
|
|
2
3
|
* Represents an HTTP error response with a status code of 401 (Unauthorized).
|
|
3
4
|
* This class is used to standardize the structure of an "Unauthorized" error response,
|
|
4
5
|
* including the response body, headers, status, and status text.
|
|
5
6
|
*/
|
|
6
|
-
declare class Unauthorized {
|
|
7
|
-
body: any;
|
|
8
|
-
cause?: any;
|
|
9
|
-
status: number;
|
|
10
|
-
statusText: string;
|
|
7
|
+
declare class Unauthorized extends BadResponse {
|
|
11
8
|
/**
|
|
12
9
|
* Creates an instance of the `Unauthorized` class.
|
|
13
10
|
*
|
|
@@ -19,14 +16,14 @@ declare class Unauthorized {
|
|
|
19
16
|
* Converts the `Unauthorized` instance into a `Response` object with a JSON body.
|
|
20
17
|
* This method ensures the response has the appropriate headers, status, and status text.
|
|
21
18
|
*
|
|
22
|
-
* @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.
|
|
23
20
|
*/
|
|
24
21
|
toResponse(): Response;
|
|
25
22
|
/**
|
|
26
23
|
* Converts the `Unauthorized` instance into a `Response` object using the `Response.json` method.
|
|
27
24
|
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
28
25
|
*
|
|
29
|
-
* @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.
|
|
30
27
|
*/
|
|
31
28
|
toJson(): Response;
|
|
32
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unauthorized.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/unauthorized.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unauthorized.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/unauthorized.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,YAAa,SAAQ,WAAW;IACpC;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAYxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BadResponse } from "./_badResponse";
|
|
2
2
|
/**
|
|
3
3
|
* Represents an HTTP error response with a status code of 401 (Unauthorized).
|
|
4
4
|
* This class is used to standardize the structure of an "Unauthorized" error response,
|
|
5
5
|
* including the response body, headers, status, and status text.
|
|
6
6
|
*/
|
|
7
|
-
class Unauthorized {
|
|
8
|
-
body;
|
|
9
|
-
cause;
|
|
10
|
-
status = 401;
|
|
11
|
-
statusText;
|
|
7
|
+
class Unauthorized extends BadResponse {
|
|
12
8
|
/**
|
|
13
9
|
* Creates an instance of the `Unauthorized` class.
|
|
14
10
|
*
|
|
@@ -16,16 +12,19 @@ class Unauthorized {
|
|
|
16
12
|
* @param cause - Optional additional information about the cause of the error.
|
|
17
13
|
*/
|
|
18
14
|
constructor(message, cause) {
|
|
19
|
-
|
|
15
|
+
super();
|
|
16
|
+
this.name = "Unauthorized";
|
|
17
|
+
this.status = 401;
|
|
20
18
|
this.statusText = message;
|
|
19
|
+
this.debugColor = "yellow";
|
|
21
20
|
this.cause = cause ? JSON.stringify(cause) : undefined;
|
|
22
|
-
|
|
21
|
+
this.onDebug();
|
|
23
22
|
}
|
|
24
23
|
/**
|
|
25
24
|
* Converts the `Unauthorized` instance into a `Response` object with a JSON body.
|
|
26
25
|
* This method ensures the response has the appropriate headers, status, and status text.
|
|
27
26
|
*
|
|
28
|
-
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
27
|
+
* @returns {Response} A `Response` object with the serialized JSON body and response metadata.
|
|
29
28
|
*/
|
|
30
29
|
toResponse() {
|
|
31
30
|
const responseInit = {
|
|
@@ -33,20 +32,20 @@ class Unauthorized {
|
|
|
33
32
|
status: this.status,
|
|
34
33
|
statusText: this.statusText,
|
|
35
34
|
};
|
|
36
|
-
return new Response(JSON.stringify(this.
|
|
35
|
+
return new Response(JSON.stringify(this.makeBody()), responseInit);
|
|
37
36
|
}
|
|
38
37
|
/**
|
|
39
38
|
* Converts the `Unauthorized` instance into a `Response` object using the `Response.json` method.
|
|
40
39
|
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
41
40
|
*
|
|
42
|
-
* @returns A `Response` object with the JSON body and response metadata.
|
|
41
|
+
* @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
|
|
43
42
|
*/
|
|
44
43
|
toJson() {
|
|
45
44
|
const responseInit = {
|
|
46
45
|
status: this.status,
|
|
47
46
|
statusText: this.statusText,
|
|
48
47
|
};
|
|
49
|
-
return Response.json(this.
|
|
48
|
+
return Response.json(this.makeBody(), responseInit);
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
export { Unauthorized };
|
|
@@ -1,41 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
data?: any;
|
|
3
|
-
fieldErrors?: Record<string, string>;
|
|
4
|
-
fields?: Record<string, string>;
|
|
5
|
-
message?: string;
|
|
6
|
-
};
|
|
1
|
+
import { BadResponse } from "./_badResponse";
|
|
7
2
|
/**
|
|
8
3
|
* Represents an HTTP error response with a status code of 422 (Unprocessable Entity).
|
|
9
4
|
* This class is used to standardize the structure of an "Unprocessable Entity" error response,
|
|
10
5
|
* including the response body, headers, status, and status text.
|
|
11
6
|
*/
|
|
12
|
-
declare class UnprocessableEntity {
|
|
13
|
-
body: any;
|
|
14
|
-
status: number;
|
|
15
|
-
statusText: string;
|
|
7
|
+
declare class UnprocessableEntity extends BadResponse {
|
|
16
8
|
/**
|
|
17
9
|
* Creates an instance of the `UnprocessableEntity` class.
|
|
18
10
|
*
|
|
19
|
-
* @param props - An object containing details about the error, such as:
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @param enableDebug - A boolean indicating whether to enable debug logging for this error.
|
|
11
|
+
* @param {object} props - An object containing details about the error, such as:
|
|
12
|
+
* @param {any} [props.data] - `data`: Additional data related to the error.
|
|
13
|
+
* @param {Record<string, string>} [props.fieldErrors] - `fieldErrors`: A record of field-specific error messages.
|
|
14
|
+
* @param {Record<string, string>} [props.fields] - `fields`: A record of field values that caused the error.
|
|
15
|
+
* @param {string} [props.message] - `message`: A descriptive message explaining the error.
|
|
25
16
|
*/
|
|
26
|
-
constructor(props:
|
|
17
|
+
constructor(props: {
|
|
18
|
+
data?: any;
|
|
19
|
+
fieldErrors?: Record<string, string>;
|
|
20
|
+
fields?: Record<string, string>;
|
|
21
|
+
message?: string;
|
|
22
|
+
});
|
|
27
23
|
/**
|
|
28
24
|
* Converts the `UnprocessableEntity` instance into a `Response` object with a JSON body.
|
|
29
25
|
* This method ensures the response has the appropriate headers, status, and status text.
|
|
30
26
|
*
|
|
31
|
-
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
27
|
+
* @returns {Response} A `Response` object with the serialized JSON body and response metadata.
|
|
32
28
|
*/
|
|
33
29
|
toResponse(): Response;
|
|
34
30
|
/**
|
|
35
31
|
* Converts the `UnprocessableEntity` instance into a `Response` object using the `Response.json` method.
|
|
36
32
|
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
37
33
|
*
|
|
38
|
-
* @returns A `Response` object with the JSON body and response metadata.
|
|
34
|
+
* @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
|
|
39
35
|
*/
|
|
40
36
|
toJson(): Response;
|
|
41
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unprocessableEntity.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/unprocessableEntity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unprocessableEntity.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/unprocessableEntity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;GAIG;AAEH,cAAM,mBAAoB,SAAQ,WAAW;IAC3C;;;;;;;;OAQG;gBAES,KAAK,EAAE;QACjB,IAAI,CAAC,EAAE,GAAG,CAAC;QACX,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACrC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAChC,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;IAgBD;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1,39 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BadResponse } from "./_badResponse";
|
|
2
2
|
/**
|
|
3
3
|
* Represents an HTTP error response with a status code of 422 (Unprocessable Entity).
|
|
4
4
|
* This class is used to standardize the structure of an "Unprocessable Entity" error response,
|
|
5
5
|
* including the response body, headers, status, and status text.
|
|
6
6
|
*/
|
|
7
|
-
class UnprocessableEntity {
|
|
8
|
-
body;
|
|
9
|
-
status = 422;
|
|
10
|
-
statusText;
|
|
7
|
+
class UnprocessableEntity extends BadResponse {
|
|
11
8
|
/**
|
|
12
9
|
* Creates an instance of the `UnprocessableEntity` class.
|
|
13
10
|
*
|
|
14
|
-
* @param props - An object containing details about the error, such as:
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @param enableDebug - A boolean indicating whether to enable debug logging for this error.
|
|
11
|
+
* @param {object} props - An object containing details about the error, such as:
|
|
12
|
+
* @param {any} [props.data] - `data`: Additional data related to the error.
|
|
13
|
+
* @param {Record<string, string>} [props.fieldErrors] - `fieldErrors`: A record of field-specific error messages.
|
|
14
|
+
* @param {Record<string, string>} [props.fields] - `fields`: A record of field values that caused the error.
|
|
15
|
+
* @param {string} [props.message] - `message`: A descriptive message explaining the error.
|
|
20
16
|
*/
|
|
21
|
-
constructor(props
|
|
22
|
-
|
|
23
|
-
this.
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
constructor(props) {
|
|
18
|
+
super();
|
|
19
|
+
this.name = "UnprocessableEntity";
|
|
20
|
+
this.status = 422;
|
|
21
|
+
this.statusText = props.message || "Unprocessable entity";
|
|
22
|
+
this.debugColor = "yellow";
|
|
23
|
+
this.cause = {
|
|
26
24
|
data: props.data,
|
|
27
25
|
fieldErrors: props.fieldErrors,
|
|
28
26
|
fields: props.fields,
|
|
29
27
|
};
|
|
30
|
-
|
|
28
|
+
this.onDebug();
|
|
31
29
|
}
|
|
32
30
|
/**
|
|
33
31
|
* Converts the `UnprocessableEntity` instance into a `Response` object with a JSON body.
|
|
34
32
|
* This method ensures the response has the appropriate headers, status, and status text.
|
|
35
33
|
*
|
|
36
|
-
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
34
|
+
* @returns {Response} A `Response` object with the serialized JSON body and response metadata.
|
|
37
35
|
*/
|
|
38
36
|
toResponse() {
|
|
39
37
|
const responseInit = {
|
|
@@ -41,20 +39,20 @@ class UnprocessableEntity {
|
|
|
41
39
|
status: this.status,
|
|
42
40
|
statusText: this.statusText,
|
|
43
41
|
};
|
|
44
|
-
return new Response(JSON.stringify(this.
|
|
42
|
+
return new Response(JSON.stringify(this.makeBody()), responseInit);
|
|
45
43
|
}
|
|
46
44
|
/**
|
|
47
45
|
* Converts the `UnprocessableEntity` instance into a `Response` object using the `Response.json` method.
|
|
48
46
|
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
49
47
|
*
|
|
50
|
-
* @returns A `Response` object with the JSON body and response metadata.
|
|
48
|
+
* @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
|
|
51
49
|
*/
|
|
52
50
|
toJson() {
|
|
53
51
|
const responseInit = {
|
|
54
52
|
status: this.status,
|
|
55
53
|
statusText: this.statusText,
|
|
56
54
|
};
|
|
57
|
-
return Response.json(this.
|
|
55
|
+
return Response.json(this.makeBody(), responseInit);
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
58
|
export { UnprocessableEntity };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for handling successful HTTP responses with debugging capabilities.
|
|
3
|
+
* Provides logging functionality to track response and their context.
|
|
4
|
+
*/
|
|
5
|
+
declare class SuccessResponse {
|
|
6
|
+
private _body;
|
|
7
|
+
private _name;
|
|
8
|
+
private _status;
|
|
9
|
+
private _statusText;
|
|
10
|
+
private _debugColor;
|
|
11
|
+
get body(): any;
|
|
12
|
+
set body(value: any);
|
|
13
|
+
get name(): string;
|
|
14
|
+
set name(value: string);
|
|
15
|
+
get status(): number;
|
|
16
|
+
set status(value: number);
|
|
17
|
+
get statusText(): string;
|
|
18
|
+
set statusText(value: string);
|
|
19
|
+
get debugColor(): "green" | "yellow" | "cyan" | "red";
|
|
20
|
+
set debugColor(value: "green" | "yellow" | "cyan" | "red");
|
|
21
|
+
/**
|
|
22
|
+
* Logs debug information for success responses including caller context and response details.
|
|
23
|
+
*
|
|
24
|
+
* @param {any} body - The response body or success data to be logged
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const SuccessResponse = new SuccessResponse();
|
|
29
|
+
* SuccessResponse.onDebug({ data: "Operation completed successfully" });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
onDebug(body?: any): void;
|
|
33
|
+
makeBody(): any;
|
|
34
|
+
}
|
|
35
|
+
export { SuccessResponse };
|
|
36
|
+
//# 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,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,WAAW,CAAgD;IAEnE,IAAI,IAAI,IAAI,GAAG,CAEd;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,GAAG,EAElB;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,IAAI,UAAU,IAAI,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAEpD;IAED,IAAI,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,EAGxD;IAED;;;;;;;;;;OAUG;IACH,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAazB,QAAQ,IAAI,GAAG;CAOhB;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { DebugService } from "../../services/debugService";
|
|
2
|
+
import { flushDebugLogs } from "../../utilities/flushDebugLogs";
|
|
3
|
+
/**
|
|
4
|
+
* Base class for handling successful HTTP responses with debugging capabilities.
|
|
5
|
+
* Provides logging functionality to track response and their context.
|
|
6
|
+
*/
|
|
7
|
+
class SuccessResponse {
|
|
8
|
+
_body = null;
|
|
9
|
+
_name = "SuccessResponse";
|
|
10
|
+
_status = 200;
|
|
11
|
+
_statusText = "OK";
|
|
12
|
+
_debugColor = "green";
|
|
13
|
+
get body() {
|
|
14
|
+
return this._body;
|
|
15
|
+
}
|
|
16
|
+
set body(value) {
|
|
17
|
+
this._body = value ?? null;
|
|
18
|
+
}
|
|
19
|
+
get name() {
|
|
20
|
+
return this._name;
|
|
21
|
+
}
|
|
22
|
+
set name(value) {
|
|
23
|
+
this._name = value;
|
|
24
|
+
}
|
|
25
|
+
get status() {
|
|
26
|
+
return this._status;
|
|
27
|
+
}
|
|
28
|
+
set status(value) {
|
|
29
|
+
this._status = value;
|
|
30
|
+
}
|
|
31
|
+
get statusText() {
|
|
32
|
+
return this._statusText;
|
|
33
|
+
}
|
|
34
|
+
set statusText(value) {
|
|
35
|
+
this._statusText = value;
|
|
36
|
+
}
|
|
37
|
+
get debugColor() {
|
|
38
|
+
return this._debugColor;
|
|
39
|
+
}
|
|
40
|
+
set debugColor(value) {
|
|
41
|
+
if (!["green", "yellow", "cyan", "red"].includes(value))
|
|
42
|
+
return;
|
|
43
|
+
this._debugColor = value;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Logs debug information for success responses including caller context and response details.
|
|
47
|
+
*
|
|
48
|
+
* @param {any} body - The response body or success data to be logged
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const SuccessResponse = new SuccessResponse();
|
|
53
|
+
* SuccessResponse.onDebug({ data: "Operation completed successfully" });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
onDebug(body) {
|
|
57
|
+
const debugs = [];
|
|
58
|
+
const { callerInfo, functionName } = DebugService.getCaller();
|
|
59
|
+
debugs.push(`Caller Function: ${functionName}`);
|
|
60
|
+
debugs.push(`Caller Location: ${callerInfo}`);
|
|
61
|
+
if (this.statusText)
|
|
62
|
+
debugs.push(`Message: ${this.statusText}`);
|
|
63
|
+
if (body)
|
|
64
|
+
debugs.push(`Body: ${JSON.stringify(body)}`);
|
|
65
|
+
flushDebugLogs({ scheme: this._debugColor, name: this.name, debugs });
|
|
66
|
+
}
|
|
67
|
+
makeBody() {
|
|
68
|
+
return {
|
|
69
|
+
name: this.name,
|
|
70
|
+
message: this.statusText,
|
|
71
|
+
body: this.body,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export { SuccessResponse };
|
|
@@ -1,34 +1,24 @@
|
|
|
1
|
+
import { SuccessResponse } from "./_successResponse";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
* This class is used to standardize the structure of a "Created" response,
|
|
4
|
-
* including the response body, headers, status, and status text.
|
|
5
|
-
*
|
|
6
|
-
* @template T - The type of the response body.
|
|
3
|
+
* Class representing a successful HTTP 201 Created response.
|
|
7
4
|
*/
|
|
8
|
-
declare class Created
|
|
9
|
-
body: T;
|
|
10
|
-
headers: ResponseInit["headers"];
|
|
11
|
-
status: number;
|
|
12
|
-
statusText: string;
|
|
5
|
+
declare class Created extends SuccessResponse {
|
|
13
6
|
/**
|
|
14
7
|
* Creates an instance of the `Created` class.
|
|
15
8
|
*
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
9
|
+
* @param {string} message - A message describing the creation status.
|
|
10
|
+
* @param {any} body - The response body to be included in the HTTP response.
|
|
18
11
|
*/
|
|
19
|
-
constructor(
|
|
12
|
+
constructor(message: string, body?: any);
|
|
20
13
|
/**
|
|
21
|
-
* Converts the `Created` instance into a `Response` object
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
14
|
+
* Converts the `Created` instance into a `Response` object.
|
|
15
|
+
* @returns {Response} A `Response` object with the body and response metadata.
|
|
25
16
|
*/
|
|
26
17
|
toResponse(): Response;
|
|
27
18
|
/**
|
|
28
19
|
* Converts the `Created` instance into a `Response` object using the `Response.json` method.
|
|
29
20
|
* This method is an alternative to `toResponse` for generating JSON responses.
|
|
30
|
-
*
|
|
31
|
-
* @returns A `Response` object with the JSON body and response metadata.
|
|
21
|
+
* @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
|
|
32
22
|
*/
|
|
33
23
|
toJson(): Response;
|
|
34
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"created.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/created.ts"],"names":[],"mappings":"AAAA
|
|
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;;GAEG;AAEH,cAAM,OAAQ,SAAQ,eAAe;IACnC;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAWvC;;;OAGG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;OAIG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -1,36 +1,29 @@
|
|
|
1
|
+
import { SuccessResponse } from "./_successResponse";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
* This class is used to standardize the structure of a "Created" response,
|
|
4
|
-
* including the response body, headers, status, and status text.
|
|
5
|
-
*
|
|
6
|
-
* @template T - The type of the response body.
|
|
3
|
+
* Class representing a successful HTTP 201 Created response.
|
|
7
4
|
*/
|
|
8
|
-
class Created {
|
|
9
|
-
body;
|
|
10
|
-
headers;
|
|
11
|
-
status;
|
|
12
|
-
statusText;
|
|
5
|
+
class Created extends SuccessResponse {
|
|
13
6
|
/**
|
|
14
7
|
* Creates an instance of the `Created` class.
|
|
15
8
|
*
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
9
|
+
* @param {string} message - A message describing the creation status.
|
|
10
|
+
* @param {any} body - The response body to be included in the HTTP response.
|
|
18
11
|
*/
|
|
19
|
-
constructor(
|
|
20
|
-
|
|
21
|
-
this.
|
|
22
|
-
this.status =
|
|
23
|
-
this.statusText =
|
|
12
|
+
constructor(message, body) {
|
|
13
|
+
super();
|
|
14
|
+
this.name = "Created";
|
|
15
|
+
this.status = 201;
|
|
16
|
+
this.statusText = message;
|
|
17
|
+
this.body = body || undefined;
|
|
18
|
+
this.onDebug();
|
|
24
19
|
}
|
|
25
20
|
/**
|
|
26
|
-
* Converts the `Created` instance into a `Response` object
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
21
|
+
* Converts the `Created` instance into a `Response` object.
|
|
22
|
+
* @returns {Response} A `Response` object with the body and response metadata.
|
|
30
23
|
*/
|
|
31
24
|
toResponse() {
|
|
32
25
|
const responseInit = {
|
|
33
|
-
headers: { "Content-Type": "application/json"
|
|
26
|
+
headers: { "Content-Type": "application/json" },
|
|
34
27
|
status: this.status,
|
|
35
28
|
statusText: this.statusText,
|
|
36
29
|
};
|
|
@@ -39,12 +32,10 @@ class Created {
|
|
|
39
32
|
/**
|
|
40
33
|
* Converts the `Created` instance into a `Response` object using the `Response.json` method.
|
|
41
34
|
* This method is an alternative to `toResponse` for generating JSON responses.
|
|
42
|
-
*
|
|
43
|
-
* @returns A `Response` object with the JSON body and response metadata.
|
|
35
|
+
* @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
|
|
44
36
|
*/
|
|
45
37
|
toJson() {
|
|
46
38
|
const responseInit = {
|
|
47
|
-
headers: this.headers,
|
|
48
39
|
status: this.status,
|
|
49
40
|
statusText: this.statusText,
|
|
50
41
|
};
|
|
@@ -1,37 +1,24 @@
|
|
|
1
|
+
import { SuccessResponse } from "./_successResponse";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
* This class is used to create a standardized HTTP response with a status of 302 (Found),
|
|
4
|
-
* including optional headers and a response body.
|
|
5
|
-
*
|
|
6
|
-
* @template T - The type of the response body.
|
|
3
|
+
* Class representing a successful HTTP 302 Found response.
|
|
7
4
|
*/
|
|
8
|
-
declare class Found
|
|
9
|
-
body: T;
|
|
10
|
-
headers: ResponseInit["headers"];
|
|
11
|
-
status: number;
|
|
12
|
-
statusText: string;
|
|
5
|
+
declare class Found extends SuccessResponse {
|
|
13
6
|
/**
|
|
14
7
|
* Creates an instance of the `Found` class.
|
|
15
8
|
*
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
* - `headers`: Additional headers to include in the response.
|
|
19
|
-
* - `status`: HTTP status code (default is 302).
|
|
20
|
-
* - `statusText`: HTTP status text (default is "Found").
|
|
9
|
+
* @param {string} message - A message describing the creation status.
|
|
10
|
+
* @param {any} body - The response body to be included in the HTTP response.
|
|
21
11
|
*/
|
|
22
|
-
constructor(
|
|
12
|
+
constructor(message: string, body?: any);
|
|
23
13
|
/**
|
|
24
14
|
* Converts the `Found` instance into a `Response` object.
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* @returns A `Response` object with the serialized JSON body and the specified headers, status, and statusText.
|
|
15
|
+
* @returns {Response} A `Response` object with the body and response metadata.
|
|
28
16
|
*/
|
|
29
17
|
toResponse(): Response;
|
|
30
18
|
/**
|
|
31
|
-
* Converts the `Found` instance into a
|
|
32
|
-
* This method is an alternative to `toResponse` for
|
|
33
|
-
*
|
|
34
|
-
* @returns A `Response` object with the JSON body and the specified headers, status, and statusText.
|
|
19
|
+
* Converts the `Found` instance into a `Response` object using the `Response.json` method.
|
|
20
|
+
* This method is an alternative to `toResponse` for generating JSON responses.
|
|
21
|
+
* @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
|
|
35
22
|
*/
|
|
36
23
|
toJson(): Response;
|
|
37
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"found.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/found.ts"],"names":[],"mappings":"AAAA
|
|
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;;GAEG;AAEH,cAAM,KAAM,SAAQ,eAAe;IACjC;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAWvC;;;OAGG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;OAIG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,KAAK,EAAE,CAAC"}
|