@arkyn/server 3.0.1-beta.142 → 3.0.1-beta.144
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/dist/bundle.js +90 -323
- package/dist/http/badResponses/badGateway.d.ts +12 -19
- package/dist/http/badResponses/badGateway.d.ts.map +1 -1
- package/dist/http/badResponses/badGateway.js +12 -19
- package/dist/http/badResponses/badRequest.d.ts +10 -19
- package/dist/http/badResponses/badRequest.d.ts.map +1 -1
- package/dist/http/badResponses/badRequest.js +10 -19
- package/dist/http/badResponses/conflict.d.ts +10 -19
- package/dist/http/badResponses/conflict.d.ts.map +1 -1
- package/dist/http/badResponses/conflict.js +10 -19
- package/dist/http/badResponses/forbidden.d.ts +10 -19
- package/dist/http/badResponses/forbidden.d.ts.map +1 -1
- package/dist/http/badResponses/forbidden.js +10 -19
- package/dist/http/badResponses/notFound.d.ts +10 -19
- package/dist/http/badResponses/notFound.d.ts.map +1 -1
- package/dist/http/badResponses/notFound.js +10 -19
- package/dist/http/badResponses/notImplemented.d.ts +10 -19
- package/dist/http/badResponses/notImplemented.d.ts.map +1 -1
- package/dist/http/badResponses/notImplemented.js +10 -19
- package/dist/http/badResponses/serverError.d.ts +10 -19
- package/dist/http/badResponses/serverError.d.ts.map +1 -1
- package/dist/http/badResponses/serverError.js +10 -19
- package/dist/http/badResponses/unauthorized.d.ts +10 -19
- package/dist/http/badResponses/unauthorized.d.ts.map +1 -1
- package/dist/http/badResponses/unauthorized.js +10 -19
- package/dist/http/badResponses/unprocessableEntity.d.ts +17 -22
- package/dist/http/badResponses/unprocessableEntity.d.ts.map +1 -1
- package/dist/http/badResponses/unprocessableEntity.js +17 -22
- package/dist/http/successResponses/created.d.ts +10 -14
- package/dist/http/successResponses/created.d.ts.map +1 -1
- package/dist/http/successResponses/created.js +10 -14
- package/dist/http/successResponses/found.d.ts +10 -14
- package/dist/http/successResponses/found.d.ts.map +1 -1
- package/dist/http/successResponses/found.js +10 -14
- package/dist/http/successResponses/noContent.d.ts +9 -7
- package/dist/http/successResponses/noContent.d.ts.map +1 -1
- package/dist/http/successResponses/noContent.js +9 -7
- package/dist/http/successResponses/success.d.ts +10 -14
- package/dist/http/successResponses/success.d.ts.map +1 -1
- package/dist/http/successResponses/success.js +10 -14
- package/dist/http/successResponses/updated.d.ts +11 -14
- package/dist/http/successResponses/updated.d.ts.map +1 -1
- package/dist/http/successResponses/updated.js +11 -14
- package/dist/services/apiService.d.ts +20 -0
- package/dist/services/apiService.d.ts.map +1 -1
- package/dist/services/apiService.js +16 -0
- package/dist/services/debugService.d.ts +10 -42
- package/dist/services/debugService.d.ts.map +1 -1
- package/dist/services/debugService.js +10 -42
- package/dist/services/logService.d.ts +5 -10
- package/dist/services/logService.d.ts.map +1 -1
- package/dist/services/logService.js +5 -10
- package/dist/utilities/decodeRequestBody.d.ts +11 -9
- package/dist/utilities/decodeRequestBody.d.ts.map +1 -1
- package/dist/utilities/decodeRequestBody.js +11 -9
- package/dist/utilities/decodeRequestErrorMessage.d.ts +12 -10
- package/dist/utilities/decodeRequestErrorMessage.d.ts.map +1 -1
- package/dist/utilities/decodeRequestErrorMessage.js +12 -10
- package/dist/utilities/errorHandler.d.ts +13 -38
- package/dist/utilities/errorHandler.d.ts.map +1 -1
- package/dist/utilities/errorHandler.js +13 -38
- package/dist/utilities/flushDebugLogs.d.ts +6 -28
- package/dist/utilities/flushDebugLogs.d.ts.map +1 -1
- package/dist/utilities/flushDebugLogs.js +6 -28
- package/dist/utilities/formAsyncParse.d.ts +7 -28
- package/dist/utilities/formAsyncParse.d.ts.map +1 -1
- package/dist/utilities/formAsyncParse.js +7 -28
- package/dist/utilities/formParse.d.ts +7 -28
- package/dist/utilities/formParse.d.ts.map +1 -1
- package/dist/utilities/formParse.js +7 -28
- package/dist/utilities/getScopedParams.d.ts +11 -19
- package/dist/utilities/getScopedParams.d.ts.map +1 -1
- package/dist/utilities/getScopedParams.js +11 -19
- package/dist/utilities/schemaValidator.d.ts +31 -102
- package/dist/utilities/schemaValidator.d.ts.map +1 -1
- package/dist/utilities/schemaValidator.js +31 -102
- package/dist/validations/validateCep.d.ts +2 -2
- package/dist/validations/validateCep.js +2 -2
- package/dist/validations/validateCnpj.d.ts +2 -2
- package/dist/validations/validateCnpj.js +2 -2
- package/dist/validations/validateCpf.d.ts +4 -11
- package/dist/validations/validateCpf.d.ts.map +1 -1
- package/dist/validations/validateCpf.js +4 -11
- package/dist/validations/validateDate.d.ts +7 -11
- package/dist/validations/validateDate.d.ts.map +1 -1
- package/dist/validations/validateDate.js +7 -11
- package/dist/validations/validateEmail.d.ts +2 -2
- package/dist/validations/validateEmail.js +2 -2
- package/dist/validations/validatePassword.d.ts +2 -2
- package/dist/validations/validatePassword.js +2 -2
- package/dist/validations/validatePhone.d.ts +6 -18
- package/dist/validations/validatePhone.d.ts.map +1 -1
- package/dist/validations/validatePhone.js +6 -18
- package/dist/validations/validateRg.d.ts +2 -2
- package/dist/validations/validateRg.js +2 -2
- package/package.json +1 -1
|
@@ -1,30 +1,21 @@
|
|
|
1
1
|
import { BadResponse } from "./_badResponse";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* HTTP 500 Internal Server Error — an unexpected condition prevented the server from fulfilling the request.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* throw new ServerError("Failed to connect to the database");
|
|
8
|
+
* ```
|
|
6
9
|
*/
|
|
7
10
|
declare class ServerError extends BadResponse {
|
|
8
11
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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.
|
|
12
|
+
* @param message - Error description.
|
|
13
|
+
* @param cause - Optional extra context (serialized to JSON).
|
|
13
14
|
*/
|
|
14
15
|
constructor(message: string, cause?: any);
|
|
15
|
-
/**
|
|
16
|
-
* Converts the `ServerError` instance into a `Response` object with a JSON body.
|
|
17
|
-
* This method ensures the response has the appropriate headers, status, and status text.
|
|
18
|
-
*
|
|
19
|
-
* @returns {Response} A `Response` object with the serialized JSON body and response metadata.
|
|
20
|
-
*/
|
|
16
|
+
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
21
17
|
toResponse(): Response;
|
|
22
|
-
/**
|
|
23
|
-
* Converts the `ServerError` instance into a `Response` object using the `Response.json` method.
|
|
24
|
-
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
25
|
-
*
|
|
26
|
-
* @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
|
|
27
|
-
*/
|
|
18
|
+
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
28
19
|
toJson(): Response;
|
|
29
20
|
}
|
|
30
21
|
export { ServerError };
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;;;;;;;GAOG;AACH,cAAM,WAAY,SAAQ,WAAW;IACnC;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAWxC,6EAA6E;IAC7E,UAAU,IAAI,QAAQ;IAUtB,uFAAuF;IACvF,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { BadResponse } from "./_badResponse";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* HTTP 500 Internal Server Error — an unexpected condition prevented the server from fulfilling the request.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* throw new ServerError("Failed to connect to the database");
|
|
8
|
+
* ```
|
|
6
9
|
*/
|
|
7
10
|
class ServerError extends BadResponse {
|
|
8
11
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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.
|
|
12
|
+
* @param message - Error description.
|
|
13
|
+
* @param cause - Optional extra context (serialized to JSON).
|
|
13
14
|
*/
|
|
14
15
|
constructor(message, cause) {
|
|
15
16
|
super();
|
|
@@ -19,12 +20,7 @@ class ServerError extends BadResponse {
|
|
|
19
20
|
this.cause = cause ? JSON.stringify(cause) : undefined;
|
|
20
21
|
this.onDebug();
|
|
21
22
|
}
|
|
22
|
-
/**
|
|
23
|
-
* Converts the `ServerError` instance into a `Response` object with a JSON body.
|
|
24
|
-
* This method ensures the response has the appropriate headers, status, and status text.
|
|
25
|
-
*
|
|
26
|
-
* @returns {Response} A `Response` object with the serialized JSON body and response metadata.
|
|
27
|
-
*/
|
|
23
|
+
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
28
24
|
toResponse() {
|
|
29
25
|
const responseInit = {
|
|
30
26
|
headers: { "Content-Type": "application/json" },
|
|
@@ -33,12 +29,7 @@ class ServerError extends BadResponse {
|
|
|
33
29
|
};
|
|
34
30
|
return new Response(JSON.stringify(this.makeBody()), responseInit);
|
|
35
31
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Converts the `ServerError` instance into a `Response` object using the `Response.json` method.
|
|
38
|
-
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
39
|
-
*
|
|
40
|
-
* @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
|
|
41
|
-
*/
|
|
32
|
+
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
42
33
|
toJson() {
|
|
43
34
|
const responseInit = {
|
|
44
35
|
status: this.status,
|
|
@@ -1,30 +1,21 @@
|
|
|
1
1
|
import { BadResponse } from "./_badResponse";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* HTTP 401 Unauthorized — the request lacks valid authentication credentials.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* throw new Unauthorized("Invalid or expired token");
|
|
8
|
+
* ```
|
|
6
9
|
*/
|
|
7
10
|
declare class Unauthorized extends BadResponse {
|
|
8
11
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @param message - A descriptive message explaining why the request is unauthorized.
|
|
12
|
-
* @param cause - Optional additional information about the cause of the error.
|
|
12
|
+
* @param message - Error description.
|
|
13
|
+
* @param cause - Optional extra context (serialized to JSON).
|
|
13
14
|
*/
|
|
14
15
|
constructor(message: string, cause?: any);
|
|
15
|
-
/**
|
|
16
|
-
* Converts the `Unauthorized` instance into a `Response` object with a JSON body.
|
|
17
|
-
* This method ensures the response has the appropriate headers, status, and status text.
|
|
18
|
-
*
|
|
19
|
-
* @returns {Response} A `Response` object with the serialized JSON body and response metadata.
|
|
20
|
-
*/
|
|
16
|
+
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
21
17
|
toResponse(): Response;
|
|
22
|
-
/**
|
|
23
|
-
* Converts the `Unauthorized` instance into a `Response` object using the `Response.json` method.
|
|
24
|
-
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
25
|
-
*
|
|
26
|
-
* @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
|
|
27
|
-
*/
|
|
18
|
+
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
28
19
|
toJson(): Response;
|
|
29
20
|
}
|
|
30
21
|
export { Unauthorized };
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;;;;;;;GAOG;AACH,cAAM,YAAa,SAAQ,WAAW;IACpC;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAYxC,6EAA6E;IAC7E,UAAU,IAAI,QAAQ;IAUtB,uFAAuF;IACvF,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { BadResponse } from "./_badResponse";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* HTTP 401 Unauthorized — the request lacks valid authentication credentials.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* throw new Unauthorized("Invalid or expired token");
|
|
8
|
+
* ```
|
|
6
9
|
*/
|
|
7
10
|
class Unauthorized extends BadResponse {
|
|
8
11
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @param message - A descriptive message explaining why the request is unauthorized.
|
|
12
|
-
* @param cause - Optional additional information about the cause of the error.
|
|
12
|
+
* @param message - Error description.
|
|
13
|
+
* @param cause - Optional extra context (serialized to JSON).
|
|
13
14
|
*/
|
|
14
15
|
constructor(message, cause) {
|
|
15
16
|
super();
|
|
@@ -20,12 +21,7 @@ class Unauthorized extends BadResponse {
|
|
|
20
21
|
this.cause = cause ? JSON.stringify(cause) : undefined;
|
|
21
22
|
this.onDebug();
|
|
22
23
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Converts the `Unauthorized` instance into a `Response` object with a JSON body.
|
|
25
|
-
* This method ensures the response has the appropriate headers, status, and status text.
|
|
26
|
-
*
|
|
27
|
-
* @returns {Response} A `Response` object with the serialized JSON body and response metadata.
|
|
28
|
-
*/
|
|
24
|
+
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
29
25
|
toResponse() {
|
|
30
26
|
const responseInit = {
|
|
31
27
|
headers: { "Content-Type": "application/json" },
|
|
@@ -34,12 +30,7 @@ class Unauthorized extends BadResponse {
|
|
|
34
30
|
};
|
|
35
31
|
return new Response(JSON.stringify(this.makeBody()), responseInit);
|
|
36
32
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Converts the `Unauthorized` instance into a `Response` object using the `Response.json` method.
|
|
39
|
-
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
40
|
-
*
|
|
41
|
-
* @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
|
|
42
|
-
*/
|
|
33
|
+
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
43
34
|
toJson() {
|
|
44
35
|
const responseInit = {
|
|
45
36
|
status: this.status,
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { BadResponse } from "./_badResponse";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* HTTP 422 Unprocessable Entity — the request is well-formed but contains semantic validation errors.
|
|
4
|
+
* Typically used for form field validation failures.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* throw new UnprocessableEntity({
|
|
9
|
+
* message: "Validation failed",
|
|
10
|
+
* fieldErrors: { email: "Invalid email format", age: "Must be 18 or older" },
|
|
11
|
+
* fields: { email: "not-an-email", age: "15" },
|
|
12
|
+
* });
|
|
13
|
+
* ```
|
|
6
14
|
*/
|
|
7
15
|
declare class UnprocessableEntity extends BadResponse {
|
|
8
16
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
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.
|
|
17
|
+
* @param props.message - Human-readable description of the error.
|
|
18
|
+
* @param props.fieldErrors - Per-field validation messages keyed by field name.
|
|
19
|
+
* @param props.fields - Original submitted field values (useful for repopulating forms).
|
|
20
|
+
* @param props.data - Any extra data to include in the response body.
|
|
16
21
|
*/
|
|
17
22
|
constructor(props: {
|
|
18
23
|
data?: any;
|
|
@@ -20,19 +25,9 @@ declare class UnprocessableEntity extends BadResponse {
|
|
|
20
25
|
fields?: Record<string, string>;
|
|
21
26
|
message?: string;
|
|
22
27
|
});
|
|
23
|
-
/**
|
|
24
|
-
* Converts the `UnprocessableEntity` instance into a `Response` object with a JSON body.
|
|
25
|
-
* This method ensures the response has the appropriate headers, status, and status text.
|
|
26
|
-
*
|
|
27
|
-
* @returns {Response} A `Response` object with the serialized JSON body and response metadata.
|
|
28
|
-
*/
|
|
28
|
+
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
29
29
|
toResponse(): Response;
|
|
30
|
-
/**
|
|
31
|
-
* Converts the `UnprocessableEntity` instance into a `Response` object using the `Response.json` method.
|
|
32
|
-
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
33
|
-
*
|
|
34
|
-
* @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
|
|
35
|
-
*/
|
|
30
|
+
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
36
31
|
toJson(): Response;
|
|
37
32
|
}
|
|
38
33
|
export { UnprocessableEntity };
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;;;;;;;;;;;;GAYG;AACH,cAAM,mBAAoB,SAAQ,WAAW;IAC3C;;;;;OAKG;gBACS,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,6EAA6E;IAC7E,UAAU,IAAI,QAAQ;IAUtB,uFAAuF;IACvF,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { BadResponse } from "./_badResponse";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* HTTP 422 Unprocessable Entity — the request is well-formed but contains semantic validation errors.
|
|
4
|
+
* Typically used for form field validation failures.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* throw new UnprocessableEntity({
|
|
9
|
+
* message: "Validation failed",
|
|
10
|
+
* fieldErrors: { email: "Invalid email format", age: "Must be 18 or older" },
|
|
11
|
+
* fields: { email: "not-an-email", age: "15" },
|
|
12
|
+
* });
|
|
13
|
+
* ```
|
|
6
14
|
*/
|
|
7
15
|
class UnprocessableEntity extends BadResponse {
|
|
8
16
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
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.
|
|
17
|
+
* @param props.message - Human-readable description of the error.
|
|
18
|
+
* @param props.fieldErrors - Per-field validation messages keyed by field name.
|
|
19
|
+
* @param props.fields - Original submitted field values (useful for repopulating forms).
|
|
20
|
+
* @param props.data - Any extra data to include in the response body.
|
|
16
21
|
*/
|
|
17
22
|
constructor(props) {
|
|
18
23
|
super();
|
|
@@ -27,12 +32,7 @@ class UnprocessableEntity extends BadResponse {
|
|
|
27
32
|
};
|
|
28
33
|
this.onDebug();
|
|
29
34
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Converts the `UnprocessableEntity` instance into a `Response` object with a JSON body.
|
|
32
|
-
* This method ensures the response has the appropriate headers, status, and status text.
|
|
33
|
-
*
|
|
34
|
-
* @returns {Response} A `Response` object with the serialized JSON body and response metadata.
|
|
35
|
-
*/
|
|
35
|
+
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
36
36
|
toResponse() {
|
|
37
37
|
const responseInit = {
|
|
38
38
|
headers: { "Content-Type": "application/json" },
|
|
@@ -41,12 +41,7 @@ class UnprocessableEntity extends BadResponse {
|
|
|
41
41
|
};
|
|
42
42
|
return new Response(JSON.stringify(this.makeBody()), responseInit);
|
|
43
43
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Converts the `UnprocessableEntity` instance into a `Response` object using the `Response.json` method.
|
|
46
|
-
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
47
|
-
*
|
|
48
|
-
* @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
|
|
49
|
-
*/
|
|
44
|
+
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
50
45
|
toJson() {
|
|
51
46
|
const responseInit = {
|
|
52
47
|
status: this.status,
|
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
import { SuccessResponse } from "./_successResponse";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* HTTP 201 Created — the request succeeded and a new resource was created.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* return new Created("User created successfully", { id: user.id }).toJson();
|
|
8
|
+
* ```
|
|
4
9
|
*/
|
|
5
10
|
declare class Created extends SuccessResponse {
|
|
6
11
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @param {string} message - A message describing the creation status.
|
|
10
|
-
* @param {any} body - The response body to be included in the HTTP response.
|
|
12
|
+
* @param message - Description included in the response status text.
|
|
13
|
+
* @param body - Data to include in the response body.
|
|
11
14
|
*/
|
|
12
15
|
constructor(message: string, body?: any);
|
|
13
|
-
/**
|
|
14
|
-
* Converts the `Created` instance into a `Response` object.
|
|
15
|
-
* @returns {Response} A `Response` object with the body and response metadata.
|
|
16
|
-
*/
|
|
16
|
+
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
17
17
|
toResponse(): Response;
|
|
18
|
-
/**
|
|
19
|
-
* Converts the `Created` 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.
|
|
22
|
-
*/
|
|
18
|
+
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
23
19
|
toJson(): Response;
|
|
24
20
|
}
|
|
25
21
|
export { Created };
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;;;;;;;GAOG;AACH,cAAM,OAAQ,SAAQ,eAAe;IACnC;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAWvC,6EAA6E;IAC7E,UAAU,IAAI,QAAQ;IAUtB,uFAAuF;IACvF,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { SuccessResponse } from "./_successResponse";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* HTTP 201 Created — the request succeeded and a new resource was created.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* return new Created("User created successfully", { id: user.id }).toJson();
|
|
8
|
+
* ```
|
|
4
9
|
*/
|
|
5
10
|
class Created extends SuccessResponse {
|
|
6
11
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @param {string} message - A message describing the creation status.
|
|
10
|
-
* @param {any} body - The response body to be included in the HTTP response.
|
|
12
|
+
* @param message - Description included in the response status text.
|
|
13
|
+
* @param body - Data to include in the response body.
|
|
11
14
|
*/
|
|
12
15
|
constructor(message, body) {
|
|
13
16
|
super();
|
|
@@ -17,10 +20,7 @@ class Created extends SuccessResponse {
|
|
|
17
20
|
this.body = body || undefined;
|
|
18
21
|
this.onDebug();
|
|
19
22
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Converts the `Created` instance into a `Response` object.
|
|
22
|
-
* @returns {Response} A `Response` object with the body and response metadata.
|
|
23
|
-
*/
|
|
23
|
+
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
24
24
|
toResponse() {
|
|
25
25
|
const responseInit = {
|
|
26
26
|
headers: { "Content-Type": "application/json" },
|
|
@@ -29,11 +29,7 @@ class Created extends SuccessResponse {
|
|
|
29
29
|
};
|
|
30
30
|
return new Response(JSON.stringify(this.body), responseInit);
|
|
31
31
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Converts the `Created` instance into a `Response` object using the `Response.json` method.
|
|
34
|
-
* This method is an alternative to `toResponse` for generating JSON responses.
|
|
35
|
-
* @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
|
|
36
|
-
*/
|
|
32
|
+
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
37
33
|
toJson() {
|
|
38
34
|
const responseInit = {
|
|
39
35
|
status: this.status,
|
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
import { SuccessResponse } from "./_successResponse";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* HTTP 302 Found — the resource was located and the response includes it in the body.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* return new Found("Products retrieved", { products }).toJson();
|
|
8
|
+
* ```
|
|
4
9
|
*/
|
|
5
10
|
declare class Found extends SuccessResponse {
|
|
6
11
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @param {string} message - A message describing the creation status.
|
|
10
|
-
* @param {any} body - The response body to be included in the HTTP response.
|
|
12
|
+
* @param message - Description included in the response status text.
|
|
13
|
+
* @param body - Data to include in the response body.
|
|
11
14
|
*/
|
|
12
15
|
constructor(message: string, body?: any);
|
|
13
|
-
/**
|
|
14
|
-
* Converts the `Found` instance into a `Response` object.
|
|
15
|
-
* @returns {Response} A `Response` object with the body and response metadata.
|
|
16
|
-
*/
|
|
16
|
+
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
17
17
|
toResponse(): Response;
|
|
18
|
-
/**
|
|
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.
|
|
22
|
-
*/
|
|
18
|
+
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
23
19
|
toJson(): Response;
|
|
24
20
|
}
|
|
25
21
|
export { Found };
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;;;;;;;GAOG;AACH,cAAM,KAAM,SAAQ,eAAe;IACjC;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAWvC,6EAA6E;IAC7E,UAAU,IAAI,QAAQ;IAUtB,uFAAuF;IACvF,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { SuccessResponse } from "./_successResponse";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* HTTP 302 Found — the resource was located and the response includes it in the body.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* return new Found("Products retrieved", { products }).toJson();
|
|
8
|
+
* ```
|
|
4
9
|
*/
|
|
5
10
|
class Found extends SuccessResponse {
|
|
6
11
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @param {string} message - A message describing the creation status.
|
|
10
|
-
* @param {any} body - The response body to be included in the HTTP response.
|
|
12
|
+
* @param message - Description included in the response status text.
|
|
13
|
+
* @param body - Data to include in the response body.
|
|
11
14
|
*/
|
|
12
15
|
constructor(message, body) {
|
|
13
16
|
super();
|
|
@@ -17,10 +20,7 @@ class Found extends SuccessResponse {
|
|
|
17
20
|
this.body = body || undefined;
|
|
18
21
|
this.onDebug();
|
|
19
22
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Converts the `Found` instance into a `Response` object.
|
|
22
|
-
* @returns {Response} A `Response` object with the body and response metadata.
|
|
23
|
-
*/
|
|
23
|
+
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
24
24
|
toResponse() {
|
|
25
25
|
const responseInit = {
|
|
26
26
|
headers: { "Content-Type": "application/json" },
|
|
@@ -29,11 +29,7 @@ class Found extends SuccessResponse {
|
|
|
29
29
|
};
|
|
30
30
|
return new Response(JSON.stringify(this.body), responseInit);
|
|
31
31
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Converts the `Found` instance into a `Response` object using the `Response.json` method.
|
|
34
|
-
* This method is an alternative to `toResponse` for generating JSON responses.
|
|
35
|
-
* @returns {Response["json"]} A `Response` object with the JSON body and response metadata.
|
|
36
|
-
*/
|
|
32
|
+
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
37
33
|
toJson() {
|
|
38
34
|
const responseInit = {
|
|
39
35
|
status: this.status,
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { SuccessResponse } from "./_successResponse";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* HTTP 204 No Content — the request succeeded but there is no content to return.
|
|
4
|
+
* Typically used for delete or update operations where a body is not needed.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* return new NoContent("Record deleted").toResponse();
|
|
9
|
+
* ```
|
|
4
10
|
*/
|
|
5
11
|
declare class NoContent extends SuccessResponse {
|
|
6
12
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @param {string} message - A message describing the creation status.
|
|
13
|
+
* @param message - Description included in the response status text.
|
|
9
14
|
*/
|
|
10
15
|
constructor(message: string);
|
|
11
|
-
/**
|
|
12
|
-
* Converts the `NoContent` instance into a `Response` object.
|
|
13
|
-
* @returns {Response} A `Response` object with the body and response metadata.
|
|
14
|
-
*/
|
|
16
|
+
/** Converts to a `Response` with `Content-Type: application/json` header and no body. */
|
|
15
17
|
toResponse(): Response;
|
|
16
18
|
}
|
|
17
19
|
export { NoContent };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noContent.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/noContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD
|
|
1
|
+
{"version":3,"file":"noContent.d.ts","sourceRoot":"","sources":["../../../src/http/successResponses/noContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;;;GAQG;AACH,cAAM,SAAU,SAAQ,eAAe;IACrC;;OAEG;gBACS,OAAO,EAAE,MAAM;IAU3B,yFAAyF;IACzF,UAAU,IAAI,QAAQ;CASvB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { SuccessResponse } from "./_successResponse";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* HTTP 204 No Content — the request succeeded but there is no content to return.
|
|
4
|
+
* Typically used for delete or update operations where a body is not needed.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* return new NoContent("Record deleted").toResponse();
|
|
9
|
+
* ```
|
|
4
10
|
*/
|
|
5
11
|
class NoContent extends SuccessResponse {
|
|
6
12
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @param {string} message - A message describing the creation status.
|
|
13
|
+
* @param message - Description included in the response status text.
|
|
9
14
|
*/
|
|
10
15
|
constructor(message) {
|
|
11
16
|
super();
|
|
@@ -14,10 +19,7 @@ class NoContent extends SuccessResponse {
|
|
|
14
19
|
this.statusText = message;
|
|
15
20
|
this.onDebug();
|
|
16
21
|
}
|
|
17
|
-
/**
|
|
18
|
-
* Converts the `NoContent` instance into a `Response` object.
|
|
19
|
-
* @returns {Response} A `Response` object with the body and response metadata.
|
|
20
|
-
*/
|
|
22
|
+
/** Converts to a `Response` with `Content-Type: application/json` header and no body. */
|
|
21
23
|
toResponse() {
|
|
22
24
|
const responseInit = {
|
|
23
25
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
import { SuccessResponse } from "./_successResponse";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* HTTP 200 OK — the request succeeded and the response body contains the result.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* return new Success("Order fetched", { order }).toJson();
|
|
8
|
+
* ```
|
|
4
9
|
*/
|
|
5
10
|
declare class Success extends SuccessResponse {
|
|
6
11
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @param {string} message - A message describing the creation status.
|
|
10
|
-
* @param {any} body - The response body to be included in the HTTP response.
|
|
12
|
+
* @param message - Description included in the response status text.
|
|
13
|
+
* @param body - Data to include in the response body.
|
|
11
14
|
*/
|
|
12
15
|
constructor(message: string, body?: any);
|
|
13
|
-
/**
|
|
14
|
-
* Converts the `Success` instance into a `Response` object.
|
|
15
|
-
* @returns {Response} A `Response` object with the body and response metadata.
|
|
16
|
-
*/
|
|
16
|
+
/** Converts to a `Response` with `Content-Type: application/json` header. */
|
|
17
17
|
toResponse(): Response;
|
|
18
|
-
/**
|
|
19
|
-
* Converts the `Success` 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.
|
|
22
|
-
*/
|
|
18
|
+
/** Converts to a `Response` using `Response.json()`. Alternative to `toResponse()`. */
|
|
23
19
|
toJson(): Response;
|
|
24
20
|
}
|
|
25
21
|
export { Success };
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;;;;;;;GAOG;AACH,cAAM,OAAQ,SAAQ,eAAe;IACnC;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG;IAWvC,6EAA6E;IAC7E,UAAU,IAAI,QAAQ;IAUtB,uFAAuF;IACvF,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|