@arkyn/server 3.0.1-beta.13 → 3.0.1-beta.131
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 +3232 -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 +88 -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} +5 -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 +191 -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 +26 -11
- 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,31 +1,26 @@
|
|
|
1
|
+
import { SuccessResponse } from "./_successResponse";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
* This class is used to standardize the structure of a "No Content" response,
|
|
4
|
-
* including headers, status, and status text.
|
|
3
|
+
* Class representing a successful HTTP 204 NoContent response.
|
|
5
4
|
*/
|
|
6
|
-
class NoContent {
|
|
7
|
-
headers;
|
|
8
|
-
status;
|
|
9
|
-
statusText;
|
|
5
|
+
class NoContent extends SuccessResponse {
|
|
10
6
|
/**
|
|
11
7
|
* Creates an instance of the `NoContent` class.
|
|
12
|
-
*
|
|
13
|
-
* @param init - Optional initialization object for customizing headers, status, and status text.
|
|
8
|
+
* @param {string} message - A message describing the creation status.
|
|
14
9
|
*/
|
|
15
|
-
constructor(
|
|
16
|
-
|
|
17
|
-
this.
|
|
18
|
-
this.
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super();
|
|
12
|
+
this.name = "NoContent";
|
|
13
|
+
this.status = 204;
|
|
14
|
+
this.statusText = message;
|
|
15
|
+
this.onDebug();
|
|
19
16
|
}
|
|
20
17
|
/**
|
|
21
18
|
* Converts the `NoContent` instance into a `Response` object.
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @returns A `Response` object with no body and response metadata.
|
|
19
|
+
* @returns {Response} A `Response` object with the body and response metadata.
|
|
25
20
|
*/
|
|
26
21
|
toResponse() {
|
|
27
22
|
const responseInit = {
|
|
28
|
-
headers:
|
|
23
|
+
headers: { "Content-Type": "application/json" },
|
|
29
24
|
status: this.status,
|
|
30
25
|
statusText: this.statusText,
|
|
31
26
|
};
|
|
@@ -1,34 +1,24 @@
|
|
|
1
|
+
import { SuccessResponse } from "./_successResponse";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
* This class is used to standardize the structure of a "Success" 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 200 Success response.
|
|
7
4
|
*/
|
|
8
|
-
declare class Success
|
|
9
|
-
body: T;
|
|
10
|
-
headers: ResponseInit["headers"];
|
|
11
|
-
status: number;
|
|
12
|
-
statusText: string;
|
|
5
|
+
declare class Success extends SuccessResponse {
|
|
13
6
|
/**
|
|
14
7
|
* Creates an instance of the `Success` 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 `Success` instance into a `Response` object
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
14
|
+
* Converts the `Success` 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 `Success` 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":"success.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/success.ts"],"names":[],"mappings":"AAAA
|
|
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;;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 "Success" 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 200 Success response.
|
|
7
4
|
*/
|
|
8
|
-
class Success {
|
|
9
|
-
body;
|
|
10
|
-
headers;
|
|
11
|
-
status;
|
|
12
|
-
statusText;
|
|
5
|
+
class Success extends SuccessResponse {
|
|
13
6
|
/**
|
|
14
7
|
* Creates an instance of the `Success` 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 = "Success";
|
|
15
|
+
this.status = 200;
|
|
16
|
+
this.statusText = message;
|
|
17
|
+
this.body = body || undefined;
|
|
18
|
+
this.onDebug();
|
|
24
19
|
}
|
|
25
20
|
/**
|
|
26
|
-
* Converts the `Success` instance into a `Response` object
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
21
|
+
* Converts the `Success` 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 Success {
|
|
|
39
32
|
/**
|
|
40
33
|
* Converts the `Success` 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,34 +1,24 @@
|
|
|
1
|
+
import { SuccessResponse } from "./_successResponse";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
* This class is used to standardize the structure of an "Updated" 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 200 Updated response.
|
|
7
4
|
*/
|
|
8
|
-
declare class Updated
|
|
9
|
-
body: T;
|
|
10
|
-
headers: ResponseInit["headers"];
|
|
11
|
-
status: number;
|
|
12
|
-
statusText: string;
|
|
5
|
+
declare class Updated extends SuccessResponse {
|
|
13
6
|
/**
|
|
14
7
|
* Creates an instance of the `Updated` 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 `Updated` instance into a `Response` object
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
14
|
+
* Converts the `Updated` 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 `Updated` 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":"updated.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/updated.ts"],"names":[],"mappings":"AAAA
|
|
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;;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 an "Updated" 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 200 Updated response.
|
|
7
4
|
*/
|
|
8
|
-
class Updated {
|
|
9
|
-
body;
|
|
10
|
-
headers;
|
|
11
|
-
status;
|
|
12
|
-
statusText;
|
|
5
|
+
class Updated extends SuccessResponse {
|
|
13
6
|
/**
|
|
14
7
|
* Creates an instance of the `Updated` 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 = "Updated";
|
|
15
|
+
this.status = 200;
|
|
16
|
+
this.statusText = message;
|
|
17
|
+
this.body = body || undefined;
|
|
18
|
+
this.onDebug();
|
|
24
19
|
}
|
|
25
20
|
/**
|
|
26
|
-
* Converts the `Updated` instance into a `Response` object
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
21
|
+
* Converts the `Updated` 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 Updated {
|
|
|
39
32
|
/**
|
|
40
33
|
* Converts the `Updated` 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
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export { ApiInstance } from "./config/apiInstance";
|
|
2
|
-
export { ArkynLogInstance } from "./config/arkynLogInstance";
|
|
3
1
|
export { BadGateway } from "./http/badResponses/badGateway";
|
|
4
2
|
export { BadRequest } from "./http/badResponses/badRequest";
|
|
5
3
|
export { Conflict } from "./http/badResponses/conflict";
|
|
@@ -14,12 +12,23 @@ export { Found } from "./http/successResponses/found";
|
|
|
14
12
|
export { NoContent } from "./http/successResponses/noContent";
|
|
15
13
|
export { Success } from "./http/successResponses/success";
|
|
16
14
|
export { Updated } from "./http/successResponses/updated";
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
24
|
-
export {
|
|
15
|
+
export { ApiService } from "./services/apiService";
|
|
16
|
+
export { DebugService } from "./services/debugService";
|
|
17
|
+
export { LogService } from "./services/logService";
|
|
18
|
+
export { decodeRequestBody } from "./utilities/decodeRequestBody";
|
|
19
|
+
export { decodeRequestErrorMessage } from "./utilities/decodeRequestErrorMessage";
|
|
20
|
+
export { errorHandler } from "./utilities/errorHandler";
|
|
21
|
+
export { flushDebugLogs } from "./utilities/flushDebugLogs";
|
|
22
|
+
export { formAsyncParse } from "./utilities/formAsyncParse";
|
|
23
|
+
export { formParse } from "./utilities/formParse";
|
|
24
|
+
export { getScopedParams } from "./utilities/getScopedParams";
|
|
25
|
+
export { SchemaValidator } from "./utilities/schemaValidator";
|
|
26
|
+
export { validateCep } from "./validations/validateCep";
|
|
27
|
+
export { validateCnpj } from "./validations/validateCnpj";
|
|
28
|
+
export { validateCpf } from "./validations/validateCpf";
|
|
29
|
+
export { validateDate } from "./validations/validateDate";
|
|
30
|
+
export { validateEmail } from "./validations/validateEmail";
|
|
31
|
+
export { validatePassword } from "./validations/validatePassword";
|
|
32
|
+
export { validatePhone } from "./validations/validatePhone";
|
|
33
|
+
export { validateRg } from "./validations/validateRg";
|
|
25
34
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
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,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAG1D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAG9D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
export { ApiInstance } from "./config/apiInstance";
|
|
3
|
-
export { ArkynLogInstance } from "./config/arkynLogInstance";
|
|
4
|
-
// http bad responses
|
|
1
|
+
// http
|
|
5
2
|
export { BadGateway } from "./http/badResponses/badGateway";
|
|
6
3
|
export { BadRequest } from "./http/badResponses/badRequest";
|
|
7
4
|
export { Conflict } from "./http/badResponses/conflict";
|
|
@@ -11,18 +8,30 @@ export { NotImplemented } from "./http/badResponses/notImplemented";
|
|
|
11
8
|
export { ServerError } from "./http/badResponses/serverError";
|
|
12
9
|
export { Unauthorized } from "./http/badResponses/unauthorized";
|
|
13
10
|
export { UnprocessableEntity } from "./http/badResponses/unprocessableEntity";
|
|
14
|
-
// http success responses
|
|
15
11
|
export { Created } from "./http/successResponses/created";
|
|
16
12
|
export { Found } from "./http/successResponses/found";
|
|
17
13
|
export { NoContent } from "./http/successResponses/noContent";
|
|
18
14
|
export { Success } from "./http/successResponses/success";
|
|
19
15
|
export { Updated } from "./http/successResponses/updated";
|
|
20
16
|
// services
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
24
|
-
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
17
|
+
export { ApiService } from "./services/apiService";
|
|
18
|
+
export { DebugService } from "./services/debugService";
|
|
19
|
+
export { LogService } from "./services/logService";
|
|
20
|
+
// utilities
|
|
21
|
+
export { decodeRequestBody } from "./utilities/decodeRequestBody";
|
|
22
|
+
export { decodeRequestErrorMessage } from "./utilities/decodeRequestErrorMessage";
|
|
23
|
+
export { errorHandler } from "./utilities/errorHandler";
|
|
24
|
+
export { flushDebugLogs } from "./utilities/flushDebugLogs";
|
|
25
|
+
export { formAsyncParse } from "./utilities/formAsyncParse";
|
|
26
|
+
export { formParse } from "./utilities/formParse";
|
|
27
|
+
export { getScopedParams } from "./utilities/getScopedParams";
|
|
28
|
+
export { SchemaValidator } from "./utilities/schemaValidator";
|
|
29
|
+
// validates
|
|
30
|
+
export { validateCep } from "./validations/validateCep";
|
|
31
|
+
export { validateCnpj } from "./validations/validateCnpj";
|
|
32
|
+
export { validateCpf } from "./validations/validateCpf";
|
|
33
|
+
export { validateDate } from "./validations/validateDate";
|
|
34
|
+
export { validateEmail } from "./validations/validateEmail";
|
|
35
|
+
export { validatePassword } from "./validations/validatePassword";
|
|
36
|
+
export { validatePhone } from "./validations/validatePhone";
|
|
37
|
+
export { validateRg } from "./validations/validateRg";
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
type ApiServiceConstructorProps = {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
baseHeaders?: HeadersInit;
|
|
4
|
+
baseToken?: string | null;
|
|
5
|
+
enableDebug?: boolean;
|
|
6
|
+
};
|
|
7
|
+
type ApiRequestDataWithoutBodyProps = {
|
|
8
|
+
headers?: HeadersInit;
|
|
9
|
+
token?: string;
|
|
10
|
+
urlParams?: Record<string, string>;
|
|
11
|
+
};
|
|
12
|
+
type ApiRequestDataWithBodyProps = {
|
|
13
|
+
body?: any;
|
|
14
|
+
headers?: HeadersInit;
|
|
15
|
+
token?: string;
|
|
16
|
+
urlParams?: Record<string, string>;
|
|
17
|
+
};
|
|
18
|
+
declare class ApiService {
|
|
19
|
+
private baseUrl;
|
|
20
|
+
private baseHeaders?;
|
|
21
|
+
private baseToken?;
|
|
22
|
+
private enableDebug?;
|
|
23
|
+
constructor(props: ApiServiceConstructorProps);
|
|
24
|
+
private onDebug;
|
|
25
|
+
private generateHeaders;
|
|
26
|
+
/**
|
|
27
|
+
* Sends a get request to the specified endpoint.
|
|
28
|
+
* @param endpoint - The API endpoint to send the get request to.
|
|
29
|
+
* @param data - The request data, including optional headers and token.
|
|
30
|
+
* @returns The API response data.
|
|
31
|
+
*/
|
|
32
|
+
get(endpoint: string, data?: ApiRequestDataWithoutBodyProps): Promise<import("../http/api/_makeRequest").ApiResponseDTO<any>>;
|
|
33
|
+
/**
|
|
34
|
+
* Sends a post request to the specified endpoint.
|
|
35
|
+
* @param endpoint - The API endpoint to send the post request to.
|
|
36
|
+
* @param data - The request data, including body, optional headers, and token.
|
|
37
|
+
* @returns The API response data.
|
|
38
|
+
*/
|
|
39
|
+
post(endpoint: string, data?: ApiRequestDataWithBodyProps): Promise<import("../http/api/_makeRequest").ApiResponseDTO<any>>;
|
|
40
|
+
/**
|
|
41
|
+
* Sends a put request to the specified endpoint.
|
|
42
|
+
* @param endpoint - The API endpoint to send the put request to.
|
|
43
|
+
* @param data - The request data, including body, optional headers, and token.
|
|
44
|
+
* @returns The API response data.
|
|
45
|
+
*/
|
|
46
|
+
put(endpoint: string, data?: ApiRequestDataWithBodyProps): Promise<import("../http/api/_makeRequest").ApiResponseDTO<any>>;
|
|
47
|
+
/**
|
|
48
|
+
* Sends a patch request to the specified endpoint.
|
|
49
|
+
* @param endpoint - The API endpoint to send the patch request to.
|
|
50
|
+
* @param data - The request data, including body, optional headers, and token.
|
|
51
|
+
* @returns The API response data.
|
|
52
|
+
*/
|
|
53
|
+
patch(endpoint: string, data?: ApiRequestDataWithBodyProps): Promise<import("../http/api/_makeRequest").ApiResponseDTO<any>>;
|
|
54
|
+
/**
|
|
55
|
+
* Sends a delete request to the specified endpoint.
|
|
56
|
+
* @param endpoint - The API endpoint to send the delete request to.
|
|
57
|
+
* @param data - The request data, including body, optional headers, and token.
|
|
58
|
+
* @returns The API response data.
|
|
59
|
+
*/
|
|
60
|
+
delete(endpoint: string, data?: ApiRequestDataWithBodyProps): Promise<import("../http/api/_makeRequest").ApiResponseDTO<any>>;
|
|
61
|
+
}
|
|
62
|
+
export { ApiService };
|
|
63
|
+
//# sourceMappingURL=apiService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiService.d.ts","sourceRoot":"","sources":["../../src/services/apiService.ts"],"names":[],"mappings":"AAOA,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;IACf,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC,CAAC;AASF,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;gBAElB,KAAK,EAAE,0BAA0B;IAO7C,OAAO,CAAC,OAAO;IAiBf,OAAO,CAAC,eAAe;IAcvB;;;;;OAKG;IAEG,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,8BAA8B;IAkBjE;;;;;OAKG;IAEG,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;IAqB/D;;;;;OAKG;IAEG,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;IAqB9D;;;;;OAKG;IAEG,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;IAqBhE;;;;;OAKG;IAEG,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;CAoBlE;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { deleteRequest } from "../http/api/deleteRequest";
|
|
2
|
+
import { getRequest } from "../http/api/getRequest";
|
|
3
|
+
import { patchRequest } from "../http/api/patchRequest";
|
|
4
|
+
import { postRequest } from "../http/api/postRequest";
|
|
5
|
+
import { putRequest } from "../http/api/putRequest";
|
|
6
|
+
import { flushDebugLogs } from "../utilities/flushDebugLogs";
|
|
7
|
+
class ApiService {
|
|
8
|
+
baseUrl;
|
|
9
|
+
baseHeaders;
|
|
10
|
+
baseToken;
|
|
11
|
+
enableDebug;
|
|
12
|
+
constructor(props) {
|
|
13
|
+
this.baseUrl = props.baseUrl;
|
|
14
|
+
this.baseHeaders = props.baseHeaders || undefined;
|
|
15
|
+
this.baseToken = props.baseToken || undefined;
|
|
16
|
+
this.enableDebug = props.enableDebug || false;
|
|
17
|
+
}
|
|
18
|
+
onDebug(endpoint, method, data) {
|
|
19
|
+
if (this.enableDebug) {
|
|
20
|
+
const debugs = [];
|
|
21
|
+
const json = (data) => JSON.stringify(data, null, 2);
|
|
22
|
+
debugs.push(`Base URL: ${this.baseUrl}`);
|
|
23
|
+
debugs.push(`Endpoint: ${endpoint}`);
|
|
24
|
+
debugs.push(`Status/Method: ${method} => ${data.status}`);
|
|
25
|
+
debugs.push(`Message: ${data.message}`);
|
|
26
|
+
if (data.headers)
|
|
27
|
+
debugs.push(`Headers: ${json(data.headers)}`);
|
|
28
|
+
if (data.body)
|
|
29
|
+
debugs.push(`Body: ${json(data.body)}`);
|
|
30
|
+
flushDebugLogs({ debugs, name: "ApiDebug", scheme: "yellow" });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
generateHeaders(initHeaders, token) {
|
|
34
|
+
let headers = {};
|
|
35
|
+
if (this.baseToken)
|
|
36
|
+
headers = { Authorization: `Bearer ${this.baseToken}` };
|
|
37
|
+
if (this.baseHeaders)
|
|
38
|
+
headers = { ...headers, ...this.baseHeaders };
|
|
39
|
+
if (initHeaders)
|
|
40
|
+
headers = { ...headers, ...initHeaders };
|
|
41
|
+
if (token)
|
|
42
|
+
headers = { ...headers, Authorization: `Bearer ${token}` };
|
|
43
|
+
return headers;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Sends a get request to the specified endpoint.
|
|
47
|
+
* @param endpoint - The API endpoint to send the get request to.
|
|
48
|
+
* @param data - The request data, including optional headers and token.
|
|
49
|
+
* @returns The API response data.
|
|
50
|
+
*/
|
|
51
|
+
async get(endpoint, data) {
|
|
52
|
+
const headers = this.generateHeaders(data?.headers || {}, data?.token);
|
|
53
|
+
const response = await getRequest({
|
|
54
|
+
url: this.baseUrl + endpoint,
|
|
55
|
+
urlParams: data?.urlParams || {},
|
|
56
|
+
headers,
|
|
57
|
+
});
|
|
58
|
+
this.onDebug(endpoint, "get", {
|
|
59
|
+
headers,
|
|
60
|
+
message: response.message,
|
|
61
|
+
status: response.status,
|
|
62
|
+
});
|
|
63
|
+
return response;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Sends a post request to the specified endpoint.
|
|
67
|
+
* @param endpoint - The API endpoint to send the post request to.
|
|
68
|
+
* @param data - The request data, including body, optional headers, and token.
|
|
69
|
+
* @returns The API response data.
|
|
70
|
+
*/
|
|
71
|
+
async post(endpoint, data) {
|
|
72
|
+
const headers = this.generateHeaders(data?.headers || {}, data?.token);
|
|
73
|
+
const body = data?.body;
|
|
74
|
+
const response = await postRequest({
|
|
75
|
+
url: this.baseUrl + endpoint,
|
|
76
|
+
urlParams: data?.urlParams || {},
|
|
77
|
+
headers,
|
|
78
|
+
body,
|
|
79
|
+
});
|
|
80
|
+
this.onDebug(endpoint, "post", {
|
|
81
|
+
headers,
|
|
82
|
+
body,
|
|
83
|
+
message: response.message,
|
|
84
|
+
status: response.status,
|
|
85
|
+
});
|
|
86
|
+
return response;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Sends a put request to the specified endpoint.
|
|
90
|
+
* @param endpoint - The API endpoint to send the put request to.
|
|
91
|
+
* @param data - The request data, including body, optional headers, and token.
|
|
92
|
+
* @returns The API response data.
|
|
93
|
+
*/
|
|
94
|
+
async put(endpoint, data) {
|
|
95
|
+
const headers = this.generateHeaders(data?.headers || {}, data?.token);
|
|
96
|
+
const body = data?.body;
|
|
97
|
+
const response = await putRequest({
|
|
98
|
+
url: this.baseUrl + endpoint,
|
|
99
|
+
urlParams: data?.urlParams || {},
|
|
100
|
+
headers,
|
|
101
|
+
body,
|
|
102
|
+
});
|
|
103
|
+
this.onDebug(endpoint, "put", {
|
|
104
|
+
headers,
|
|
105
|
+
body,
|
|
106
|
+
message: response.message,
|
|
107
|
+
status: response.status,
|
|
108
|
+
});
|
|
109
|
+
return response;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Sends a patch request to the specified endpoint.
|
|
113
|
+
* @param endpoint - The API endpoint to send the patch request to.
|
|
114
|
+
* @param data - The request data, including body, optional headers, and token.
|
|
115
|
+
* @returns The API response data.
|
|
116
|
+
*/
|
|
117
|
+
async patch(endpoint, data) {
|
|
118
|
+
const headers = this.generateHeaders(data?.headers || {}, data?.token);
|
|
119
|
+
const body = data?.body;
|
|
120
|
+
const response = await patchRequest({
|
|
121
|
+
url: this.baseUrl + endpoint,
|
|
122
|
+
urlParams: data?.urlParams || {},
|
|
123
|
+
headers,
|
|
124
|
+
body,
|
|
125
|
+
});
|
|
126
|
+
this.onDebug(endpoint, "patch", {
|
|
127
|
+
headers,
|
|
128
|
+
body,
|
|
129
|
+
message: response.message,
|
|
130
|
+
status: response.status,
|
|
131
|
+
});
|
|
132
|
+
return response;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Sends a delete request to the specified endpoint.
|
|
136
|
+
* @param endpoint - The API endpoint to send the delete request to.
|
|
137
|
+
* @param data - The request data, including body, optional headers, and token.
|
|
138
|
+
* @returns The API response data.
|
|
139
|
+
*/
|
|
140
|
+
async delete(endpoint, data) {
|
|
141
|
+
const headers = this.generateHeaders(data?.headers || {}, data?.token);
|
|
142
|
+
const body = data?.body;
|
|
143
|
+
const response = await deleteRequest({
|
|
144
|
+
url: this.baseUrl + endpoint,
|
|
145
|
+
urlParams: data?.urlParams || {},
|
|
146
|
+
headers,
|
|
147
|
+
body,
|
|
148
|
+
});
|
|
149
|
+
this.onDebug(endpoint, "delete", {
|
|
150
|
+
headers,
|
|
151
|
+
body,
|
|
152
|
+
message: response.message,
|
|
153
|
+
status: response.status,
|
|
154
|
+
});
|
|
155
|
+
return response;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
export { ApiService };
|