@arkyn/server 2.0.1-beta.10 → 2.0.1-beta.12
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/config/arkynInstance.d.ts +28 -0
- package/dist/config/arkynInstance.d.ts.map +1 -0
- package/dist/config/arkynInstance.js +28 -0
- package/dist/http/badResponses/badGateway.d.ts +23 -0
- package/dist/http/badResponses/badGateway.d.ts.map +1 -1
- package/dist/http/badResponses/badGateway.js +23 -0
- package/dist/http/badResponses/badRequest.d.ts +23 -0
- package/dist/http/badResponses/badRequest.d.ts.map +1 -1
- package/dist/http/badResponses/badRequest.js +23 -0
- package/dist/http/badResponses/conflict.d.ts +23 -0
- package/dist/http/badResponses/conflict.d.ts.map +1 -1
- package/dist/http/badResponses/conflict.js +23 -0
- package/dist/http/badResponses/forbidden.d.ts +23 -0
- package/dist/http/badResponses/forbidden.d.ts.map +1 -1
- package/dist/http/badResponses/forbidden.js +24 -1
- package/dist/http/badResponses/notFound.d.ts +23 -0
- package/dist/http/badResponses/notFound.d.ts.map +1 -1
- package/dist/http/badResponses/notFound.js +23 -0
- package/dist/http/badResponses/notImplemented.d.ts +23 -0
- package/dist/http/badResponses/notImplemented.d.ts.map +1 -1
- package/dist/http/badResponses/notImplemented.js +23 -0
- package/dist/http/badResponses/serverError.d.ts +23 -0
- package/dist/http/badResponses/serverError.d.ts.map +1 -1
- package/dist/http/badResponses/serverError.js +23 -0
- package/dist/http/badResponses/unauthorized.d.ts +23 -0
- package/dist/http/badResponses/unauthorized.d.ts.map +1 -1
- package/dist/http/badResponses/unauthorized.js +23 -0
- package/dist/http/badResponses/unprocessableEntity.d.ts +27 -0
- package/dist/http/badResponses/unprocessableEntity.d.ts.map +1 -1
- package/dist/http/badResponses/unprocessableEntity.js +27 -0
- package/dist/http/successResponses/created.d.ts +25 -0
- package/dist/http/successResponses/created.d.ts.map +1 -1
- package/dist/http/successResponses/created.js +25 -0
- package/dist/http/successResponses/found.d.ts +28 -0
- package/dist/http/successResponses/found.d.ts.map +1 -1
- package/dist/http/successResponses/found.js +28 -0
- package/dist/http/successResponses/noContent.d.ts +16 -1
- package/dist/http/successResponses/noContent.d.ts.map +1 -1
- package/dist/http/successResponses/noContent.js +16 -8
- package/dist/http/successResponses/success.d.ts +25 -0
- package/dist/http/successResponses/success.d.ts.map +1 -1
- package/dist/http/successResponses/success.js +25 -0
- package/dist/http/successResponses/updated.d.ts +25 -0
- package/dist/http/successResponses/updated.d.ts.map +1 -1
- package/dist/http/successResponses/updated.js +25 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/services/decodeRequestBody.d.ts.map +1 -1
- package/dist/services/decodeRequestBody.js +12 -16
- package/dist/services/errorHandler.d.ts +42 -1
- package/dist/services/errorHandler.d.ts.map +1 -1
- package/dist/services/errorHandler.js +42 -0
- package/dist/services/formParse.d.ts.map +1 -1
- package/dist/services/formParse.js +4 -2
- package/dist/services/getCaller.d.ts +11 -0
- package/dist/services/getCaller.d.ts.map +1 -1
- package/dist/services/getCaller.js +32 -16
- package/dist/services/httpDebug.d.ts +32 -0
- package/dist/services/httpDebug.d.ts.map +1 -1
- package/dist/services/httpDebug.js +44 -6
- package/package.json +4 -2
- package/src/config/arkynInstance.ts +37 -0
- package/src/http/badResponses/badGateway.ts +29 -2
- package/src/http/badResponses/badRequest.ts +29 -2
- package/src/http/badResponses/conflict.ts +29 -2
- package/src/http/badResponses/forbidden.ts +30 -3
- package/src/http/badResponses/notFound.ts +29 -2
- package/src/http/badResponses/notImplemented.ts +29 -2
- package/src/http/badResponses/serverError.ts +29 -2
- package/src/http/badResponses/unauthorized.ts +29 -2
- package/src/http/badResponses/unprocessableEntity.ts +33 -2
- package/src/http/successResponses/created.ts +31 -2
- package/src/http/successResponses/found.ts +32 -0
- package/src/http/successResponses/noContent.ts +20 -11
- package/src/http/successResponses/success.ts +31 -2
- package/src/http/successResponses/updated.ts +31 -2
- package/src/index.ts +3 -1
- package/src/services/decodeRequestBody.ts +11 -15
- package/src/services/errorHandler.ts +45 -1
- package/src/services/formParse.ts +4 -5
- package/src/services/getCaller.ts +39 -18
- package/src/services/httpDebug.ts +46 -5
- package/vitest.config.ts +5 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type InboxKeysProps = {
|
|
2
|
+
inboxKey: string;
|
|
3
|
+
inboxUserToken: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* The `ArkynInstance` class is a singleton-like utility designed to manage and provide access
|
|
7
|
+
* to inbox configuration keys (`InboxKeysProps`) within the application. It ensures that the
|
|
8
|
+
* inbox keys are set before they can be retrieved, throwing an error if they are accessed
|
|
9
|
+
* without being initialized.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // Setting the inbox keys
|
|
14
|
+
* ArkynInstance.setInboxKeys({ key1: "value1", key2: "value2" });
|
|
15
|
+
*
|
|
16
|
+
* // Retrieving the inbox keys
|
|
17
|
+
* const inboxKeys = ArkynInstance.getInboxKeys();
|
|
18
|
+
* console.log(inboxKeys);
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare class ArkynInstance {
|
|
22
|
+
static inboxKeys?: InboxKeysProps;
|
|
23
|
+
constructor();
|
|
24
|
+
static setInboxKeys(arkynConfig: InboxKeysProps): void;
|
|
25
|
+
static getInboxKeys(): InboxKeysProps | undefined;
|
|
26
|
+
}
|
|
27
|
+
export { ArkynInstance };
|
|
28
|
+
//# sourceMappingURL=arkynInstance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arkynInstance.d.ts","sourceRoot":"","sources":["../../src/config/arkynInstance.ts"],"names":[],"mappings":"AAAA,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AAEH,cAAM,aAAa;IACjB,MAAM,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC;;IAIlC,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,cAAc;IAI/C,MAAM,CAAC,YAAY;CAGpB;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `ArkynInstance` class is a singleton-like utility designed to manage and provide access
|
|
3
|
+
* to inbox configuration keys (`InboxKeysProps`) within the application. It ensures that the
|
|
4
|
+
* inbox keys are set before they can be retrieved, throwing an error if they are accessed
|
|
5
|
+
* without being initialized.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // Setting the inbox keys
|
|
10
|
+
* ArkynInstance.setInboxKeys({ key1: "value1", key2: "value2" });
|
|
11
|
+
*
|
|
12
|
+
* // Retrieving the inbox keys
|
|
13
|
+
* const inboxKeys = ArkynInstance.getInboxKeys();
|
|
14
|
+
* console.log(inboxKeys);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
class ArkynInstance {
|
|
18
|
+
static inboxKeys;
|
|
19
|
+
constructor() { }
|
|
20
|
+
static setInboxKeys(arkynConfig) {
|
|
21
|
+
if (!this.inboxKeys)
|
|
22
|
+
this.inboxKeys = arkynConfig;
|
|
23
|
+
}
|
|
24
|
+
static getInboxKeys() {
|
|
25
|
+
return this.inboxKeys;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export { ArkynInstance };
|
|
@@ -1,10 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an HTTP error response with a status code of 502 (Bad Gateway).
|
|
3
|
+
* This class is used to standardize the structure of a "Bad Gateway" error response,
|
|
4
|
+
* including the response body, headers, status, and status text.
|
|
5
|
+
*/
|
|
1
6
|
declare class BadGateway {
|
|
2
7
|
body: any;
|
|
3
8
|
cause?: any;
|
|
4
9
|
status: number;
|
|
5
10
|
statusText: string;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of the `BadGateway` class.
|
|
13
|
+
*
|
|
14
|
+
* @param message - A descriptive message explaining the cause of the error.
|
|
15
|
+
* @param cause - Optional additional information about the cause of the error.
|
|
16
|
+
*/
|
|
6
17
|
constructor(message: string, cause?: any);
|
|
18
|
+
/**
|
|
19
|
+
* Converts the `BadGateway` instance into a `Response` object with a JSON body.
|
|
20
|
+
* This method ensures the response has the appropriate headers, status, and status text.
|
|
21
|
+
*
|
|
22
|
+
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
23
|
+
*/
|
|
7
24
|
toResponse(): Response;
|
|
25
|
+
/**
|
|
26
|
+
* Converts the `BadGateway` instance into a `Response` object using the `Response.json` method.
|
|
27
|
+
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
28
|
+
*
|
|
29
|
+
* @returns A `Response` object with the JSON body and response metadata.
|
|
30
|
+
*/
|
|
8
31
|
toJson(): Response;
|
|
9
32
|
}
|
|
10
33
|
export { BadGateway };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badGateway.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/badGateway.ts"],"names":[],"mappings":"AAEA,cAAM,UAAU;IACd,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"badGateway.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/badGateway.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,cAAM,UAAU;IACd,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
import { httpDebug } from "../../services/httpDebug";
|
|
2
|
+
/**
|
|
3
|
+
* Represents an HTTP error response with a status code of 502 (Bad Gateway).
|
|
4
|
+
* This class is used to standardize the structure of a "Bad Gateway" error response,
|
|
5
|
+
* including the response body, headers, status, and status text.
|
|
6
|
+
*/
|
|
2
7
|
class BadGateway {
|
|
3
8
|
body;
|
|
4
9
|
cause;
|
|
5
10
|
status = 502;
|
|
6
11
|
statusText;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of the `BadGateway` class.
|
|
14
|
+
*
|
|
15
|
+
* @param message - A descriptive message explaining the cause of the error.
|
|
16
|
+
* @param cause - Optional additional information about the cause of the error.
|
|
17
|
+
*/
|
|
7
18
|
constructor(message, cause) {
|
|
8
19
|
this.body = { name: "BadGateway", message: message };
|
|
9
20
|
this.statusText = message;
|
|
10
21
|
this.cause = cause ? JSON.stringify(cause) : undefined;
|
|
11
22
|
httpDebug("BadGateway", this.body, this.cause);
|
|
12
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Converts the `BadGateway` instance into a `Response` object with a JSON body.
|
|
26
|
+
* This method ensures the response has the appropriate headers, status, and status text.
|
|
27
|
+
*
|
|
28
|
+
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
29
|
+
*/
|
|
13
30
|
toResponse() {
|
|
14
31
|
const responseInit = {
|
|
15
32
|
headers: { "Content-Type": "application/json" },
|
|
@@ -18,6 +35,12 @@ class BadGateway {
|
|
|
18
35
|
};
|
|
19
36
|
return new Response(JSON.stringify(this.body), responseInit);
|
|
20
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Converts the `BadGateway` instance into a `Response` object using the `Response.json` method.
|
|
40
|
+
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
41
|
+
*
|
|
42
|
+
* @returns A `Response` object with the JSON body and response metadata.
|
|
43
|
+
*/
|
|
21
44
|
toJson() {
|
|
22
45
|
const responseInit = {
|
|
23
46
|
status: this.status,
|
|
@@ -1,10 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an HTTP error response with a status code of 400 (Bad Request).
|
|
3
|
+
* This class is used to standardize the structure of a "Bad Request" error response,
|
|
4
|
+
* including the response body, headers, status, and status text.
|
|
5
|
+
*/
|
|
1
6
|
declare class BadRequest {
|
|
2
7
|
body: any;
|
|
3
8
|
cause?: any;
|
|
4
9
|
status: number;
|
|
5
10
|
statusText: string;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of the `BadRequest` class.
|
|
13
|
+
*
|
|
14
|
+
* @param message - A descriptive message explaining the cause of the error.
|
|
15
|
+
* @param cause - Optional additional information about the cause of the error.
|
|
16
|
+
*/
|
|
6
17
|
constructor(message: string, cause?: any);
|
|
18
|
+
/**
|
|
19
|
+
* Converts the `BadRequest` instance into a `Response` object with a JSON body.
|
|
20
|
+
* This method ensures the response has the appropriate headers, status, and status text.
|
|
21
|
+
*
|
|
22
|
+
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
23
|
+
*/
|
|
7
24
|
toResponse(): Response;
|
|
25
|
+
/**
|
|
26
|
+
* Converts the `BadRequest` instance into a `Response` object using the `Response.json` method.
|
|
27
|
+
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
28
|
+
*
|
|
29
|
+
* @returns A `Response` object with the JSON body and response metadata.
|
|
30
|
+
*/
|
|
8
31
|
toJson(): Response;
|
|
9
32
|
}
|
|
10
33
|
export { BadRequest };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badRequest.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/badRequest.ts"],"names":[],"mappings":"AAEA,cAAM,UAAU;IACd,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"badRequest.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/badRequest.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,cAAM,UAAU;IACd,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
import { httpDebug } from "../../services/httpDebug";
|
|
2
|
+
/**
|
|
3
|
+
* Represents an HTTP error response with a status code of 400 (Bad Request).
|
|
4
|
+
* This class is used to standardize the structure of a "Bad Request" error response,
|
|
5
|
+
* including the response body, headers, status, and status text.
|
|
6
|
+
*/
|
|
2
7
|
class BadRequest {
|
|
3
8
|
body;
|
|
4
9
|
cause;
|
|
5
10
|
status = 400;
|
|
6
11
|
statusText;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of the `BadRequest` class.
|
|
14
|
+
*
|
|
15
|
+
* @param message - A descriptive message explaining the cause of the error.
|
|
16
|
+
* @param cause - Optional additional information about the cause of the error.
|
|
17
|
+
*/
|
|
7
18
|
constructor(message, cause) {
|
|
8
19
|
this.body = { name: "BadRequest", message: message };
|
|
9
20
|
this.statusText = message;
|
|
10
21
|
this.cause = cause ? JSON.stringify(cause) : undefined;
|
|
11
22
|
httpDebug("BadRequest", this.body, this.cause);
|
|
12
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Converts the `BadRequest` instance into a `Response` object with a JSON body.
|
|
26
|
+
* This method ensures the response has the appropriate headers, status, and status text.
|
|
27
|
+
*
|
|
28
|
+
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
29
|
+
*/
|
|
13
30
|
toResponse() {
|
|
14
31
|
const responseInit = {
|
|
15
32
|
headers: { "Content-Type": "application/json" },
|
|
@@ -18,6 +35,12 @@ class BadRequest {
|
|
|
18
35
|
};
|
|
19
36
|
return new Response(JSON.stringify(this.body), responseInit);
|
|
20
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Converts the `BadRequest` instance into a `Response` object using the `Response.json` method.
|
|
40
|
+
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
41
|
+
*
|
|
42
|
+
* @returns A `Response` object with the JSON body and response metadata.
|
|
43
|
+
*/
|
|
21
44
|
toJson() {
|
|
22
45
|
const responseInit = {
|
|
23
46
|
status: this.status,
|
|
@@ -1,10 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an HTTP error response with a status code of 409 (Conflict).
|
|
3
|
+
* This class is used to standardize the structure of a "Conflict" error response,
|
|
4
|
+
* including the response body, headers, status, and status text.
|
|
5
|
+
*/
|
|
1
6
|
declare class Conflict {
|
|
2
7
|
body: any;
|
|
3
8
|
cause?: any;
|
|
4
9
|
status: number;
|
|
5
10
|
statusText: string;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of the `Conflict` class.
|
|
13
|
+
*
|
|
14
|
+
* @param message - A descriptive message explaining the cause of the conflict.
|
|
15
|
+
* @param cause - Optional additional information about the cause of the conflict.
|
|
16
|
+
*/
|
|
6
17
|
constructor(message: string, cause?: any);
|
|
18
|
+
/**
|
|
19
|
+
* Converts the `Conflict` instance into a `Response` object with a JSON body.
|
|
20
|
+
* This method ensures the response has the appropriate headers, status, and status text.
|
|
21
|
+
*
|
|
22
|
+
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
23
|
+
*/
|
|
7
24
|
toResponse(): Response;
|
|
25
|
+
/**
|
|
26
|
+
* Converts the `Conflict` instance into a `Response` object using the `Response.json` method.
|
|
27
|
+
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
28
|
+
*
|
|
29
|
+
* @returns A `Response` object with the JSON body and response metadata.
|
|
30
|
+
*/
|
|
8
31
|
toJson(): Response;
|
|
9
32
|
}
|
|
10
33
|
export { Conflict };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conflict.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/conflict.ts"],"names":[],"mappings":"AAEA,cAAM,QAAQ;IACZ,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"conflict.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/conflict.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,cAAM,QAAQ;IACZ,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
import { httpDebug } from "../../services/httpDebug";
|
|
2
|
+
/**
|
|
3
|
+
* Represents an HTTP error response with a status code of 409 (Conflict).
|
|
4
|
+
* This class is used to standardize the structure of a "Conflict" error response,
|
|
5
|
+
* including the response body, headers, status, and status text.
|
|
6
|
+
*/
|
|
2
7
|
class Conflict {
|
|
3
8
|
body;
|
|
4
9
|
cause;
|
|
5
10
|
status = 409;
|
|
6
11
|
statusText;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of the `Conflict` class.
|
|
14
|
+
*
|
|
15
|
+
* @param message - A descriptive message explaining the cause of the conflict.
|
|
16
|
+
* @param cause - Optional additional information about the cause of the conflict.
|
|
17
|
+
*/
|
|
7
18
|
constructor(message, cause) {
|
|
8
19
|
this.body = { name: "Conflict", message: message };
|
|
9
20
|
this.statusText = message;
|
|
10
21
|
this.cause = cause ? JSON.stringify(cause) : undefined;
|
|
11
22
|
httpDebug("Conflict", this.body, this.cause);
|
|
12
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Converts the `Conflict` instance into a `Response` object with a JSON body.
|
|
26
|
+
* This method ensures the response has the appropriate headers, status, and status text.
|
|
27
|
+
*
|
|
28
|
+
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
29
|
+
*/
|
|
13
30
|
toResponse() {
|
|
14
31
|
const responseInit = {
|
|
15
32
|
headers: { "Content-Type": "application/json" },
|
|
@@ -18,6 +35,12 @@ class Conflict {
|
|
|
18
35
|
};
|
|
19
36
|
return new Response(JSON.stringify(this.body), responseInit);
|
|
20
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Converts the `Conflict` instance into a `Response` object using the `Response.json` method.
|
|
40
|
+
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
41
|
+
*
|
|
42
|
+
* @returns A `Response` object with the JSON body and response metadata.
|
|
43
|
+
*/
|
|
21
44
|
toJson() {
|
|
22
45
|
const responseInit = {
|
|
23
46
|
status: this.status,
|
|
@@ -1,10 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an HTTP error response with a status code of 403 (Forbidden).
|
|
3
|
+
* This class is used to standardize the structure of a "Forbidden" error response,
|
|
4
|
+
* including the response body, headers, status, and status text.
|
|
5
|
+
*/
|
|
1
6
|
declare class Forbidden {
|
|
2
7
|
body: any;
|
|
3
8
|
cause?: any;
|
|
4
9
|
status: number;
|
|
5
10
|
statusText: string;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of the `Forbidden` class.
|
|
13
|
+
*
|
|
14
|
+
* @param message - A descriptive message explaining why access is forbidden.
|
|
15
|
+
* @param cause - Optional additional information about the cause of the error.
|
|
16
|
+
*/
|
|
6
17
|
constructor(message: string, cause?: any);
|
|
18
|
+
/**
|
|
19
|
+
* Converts the `Forbidden` instance into a `Response` object with a JSON body.
|
|
20
|
+
* This method ensures the response has the appropriate headers, status, and status text.
|
|
21
|
+
*
|
|
22
|
+
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
23
|
+
*/
|
|
7
24
|
toResponse(): Response;
|
|
25
|
+
/**
|
|
26
|
+
* Converts the `Forbidden` instance into a `Response` object using the `Response.json` method.
|
|
27
|
+
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
28
|
+
*
|
|
29
|
+
* @returns A `Response` object with the JSON body and response metadata.
|
|
30
|
+
*/
|
|
8
31
|
toJson(): Response;
|
|
9
32
|
}
|
|
10
33
|
export { Forbidden };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forbidden.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/forbidden.ts"],"names":[],"mappings":"AAEA,cAAM,SAAS;IACb,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"forbidden.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/forbidden.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,cAAM,SAAS;IACb,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
import { httpDebug } from "../../services/httpDebug";
|
|
2
|
+
/**
|
|
3
|
+
* Represents an HTTP error response with a status code of 403 (Forbidden).
|
|
4
|
+
* This class is used to standardize the structure of a "Forbidden" error response,
|
|
5
|
+
* including the response body, headers, status, and status text.
|
|
6
|
+
*/
|
|
2
7
|
class Forbidden {
|
|
3
8
|
body;
|
|
4
9
|
cause;
|
|
5
|
-
status =
|
|
10
|
+
status = 403;
|
|
6
11
|
statusText;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of the `Forbidden` class.
|
|
14
|
+
*
|
|
15
|
+
* @param message - A descriptive message explaining why access is forbidden.
|
|
16
|
+
* @param cause - Optional additional information about the cause of the error.
|
|
17
|
+
*/
|
|
7
18
|
constructor(message, cause) {
|
|
8
19
|
this.body = { name: "Forbidden", message: message };
|
|
9
20
|
this.statusText = message;
|
|
10
21
|
this.cause = cause ? JSON.stringify(cause) : undefined;
|
|
11
22
|
httpDebug("Forbidden", this.body, this.cause);
|
|
12
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Converts the `Forbidden` instance into a `Response` object with a JSON body.
|
|
26
|
+
* This method ensures the response has the appropriate headers, status, and status text.
|
|
27
|
+
*
|
|
28
|
+
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
29
|
+
*/
|
|
13
30
|
toResponse() {
|
|
14
31
|
const responseInit = {
|
|
15
32
|
headers: { "Content-Type": "application/json" },
|
|
@@ -18,6 +35,12 @@ class Forbidden {
|
|
|
18
35
|
};
|
|
19
36
|
return new Response(JSON.stringify(this.body), responseInit);
|
|
20
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Converts the `Forbidden` instance into a `Response` object using the `Response.json` method.
|
|
40
|
+
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
41
|
+
*
|
|
42
|
+
* @returns A `Response` object with the JSON body and response metadata.
|
|
43
|
+
*/
|
|
21
44
|
toJson() {
|
|
22
45
|
const responseInit = {
|
|
23
46
|
status: this.status,
|
|
@@ -1,10 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an HTTP error response with a status code of 404 (Not Found).
|
|
3
|
+
* This class is used to standardize the structure of a "Not Found" error response,
|
|
4
|
+
* including the response body, headers, status, and status text.
|
|
5
|
+
*/
|
|
1
6
|
declare class NotFound {
|
|
2
7
|
body: any;
|
|
3
8
|
cause?: any;
|
|
4
9
|
status: number;
|
|
5
10
|
statusText: string;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of the `NotFound` class.
|
|
13
|
+
*
|
|
14
|
+
* @param message - A descriptive message explaining the reason the resource was not found.
|
|
15
|
+
* @param cause - Optional additional information about the cause of the error.
|
|
16
|
+
*/
|
|
6
17
|
constructor(message: string, cause?: any);
|
|
18
|
+
/**
|
|
19
|
+
* Converts the `NotFound` instance into a `Response` object with a JSON body.
|
|
20
|
+
* This method ensures the response has the appropriate headers, status, and status text.
|
|
21
|
+
*
|
|
22
|
+
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
23
|
+
*/
|
|
7
24
|
toResponse(): Response;
|
|
25
|
+
/**
|
|
26
|
+
* Converts the `NotFound` instance into a `Response` object using the `Response.json` method.
|
|
27
|
+
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
28
|
+
*
|
|
29
|
+
* @returns A `Response` object with the JSON body and response metadata.
|
|
30
|
+
*/
|
|
8
31
|
toJson(): Response;
|
|
9
32
|
}
|
|
10
33
|
export { NotFound };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notFound.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/notFound.ts"],"names":[],"mappings":"AAEA,cAAM,QAAQ;IACZ,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"notFound.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/notFound.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,cAAM,QAAQ;IACZ,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
import { httpDebug } from "../../services/httpDebug";
|
|
2
|
+
/**
|
|
3
|
+
* Represents an HTTP error response with a status code of 404 (Not Found).
|
|
4
|
+
* This class is used to standardize the structure of a "Not Found" error response,
|
|
5
|
+
* including the response body, headers, status, and status text.
|
|
6
|
+
*/
|
|
2
7
|
class NotFound {
|
|
3
8
|
body;
|
|
4
9
|
cause;
|
|
5
10
|
status = 404;
|
|
6
11
|
statusText;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of the `NotFound` class.
|
|
14
|
+
*
|
|
15
|
+
* @param message - A descriptive message explaining the reason the resource was not found.
|
|
16
|
+
* @param cause - Optional additional information about the cause of the error.
|
|
17
|
+
*/
|
|
7
18
|
constructor(message, cause) {
|
|
8
19
|
this.body = { name: "NotFound", message: message };
|
|
9
20
|
this.statusText = message;
|
|
10
21
|
this.cause = cause ? JSON.stringify(cause) : undefined;
|
|
11
22
|
httpDebug("NotFound", this.body, this.cause);
|
|
12
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Converts the `NotFound` instance into a `Response` object with a JSON body.
|
|
26
|
+
* This method ensures the response has the appropriate headers, status, and status text.
|
|
27
|
+
*
|
|
28
|
+
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
29
|
+
*/
|
|
13
30
|
toResponse() {
|
|
14
31
|
const responseInit = {
|
|
15
32
|
headers: { "Content-Type": "application/json" },
|
|
@@ -18,6 +35,12 @@ class NotFound {
|
|
|
18
35
|
};
|
|
19
36
|
return new Response(JSON.stringify(this.body), responseInit);
|
|
20
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Converts the `NotFound` instance into a `Response` object using the `Response.json` method.
|
|
40
|
+
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
41
|
+
*
|
|
42
|
+
* @returns A `Response` object with the JSON body and response metadata.
|
|
43
|
+
*/
|
|
21
44
|
toJson() {
|
|
22
45
|
const responseInit = {
|
|
23
46
|
status: this.status,
|
|
@@ -1,10 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an HTTP error response with a status code of 501 (Not Implemented).
|
|
3
|
+
* This class is used to standardize the structure of a "Not Implemented" error response,
|
|
4
|
+
* including the response body, headers, status, and status text.
|
|
5
|
+
*/
|
|
1
6
|
declare class NotImplemented {
|
|
2
7
|
body: any;
|
|
3
8
|
cause?: any;
|
|
4
9
|
status: number;
|
|
5
10
|
statusText: string;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of the `NotImplemented` class.
|
|
13
|
+
*
|
|
14
|
+
* @param message - A descriptive message explaining why the functionality is not implemented.
|
|
15
|
+
* @param cause - Optional additional information about the cause of the error.
|
|
16
|
+
*/
|
|
6
17
|
constructor(message: string, cause?: any);
|
|
18
|
+
/**
|
|
19
|
+
* Converts the `NotImplemented` instance into a `Response` object with a JSON body.
|
|
20
|
+
* This method ensures the response has the appropriate headers, status, and status text.
|
|
21
|
+
*
|
|
22
|
+
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
23
|
+
*/
|
|
7
24
|
toResponse(): Response;
|
|
25
|
+
/**
|
|
26
|
+
* Converts the `NotImplemented` instance into a `Response` object using the `Response.json` method.
|
|
27
|
+
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
28
|
+
*
|
|
29
|
+
* @returns A `Response` object with the JSON body and response metadata.
|
|
30
|
+
*/
|
|
8
31
|
toJson(): Response;
|
|
9
32
|
}
|
|
10
33
|
export { NotImplemented };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notImplemented.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/notImplemented.ts"],"names":[],"mappings":"AAEA,cAAM,cAAc;IAClB,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"notImplemented.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/notImplemented.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,cAAM,cAAc;IAClB,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
import { httpDebug } from "../../services/httpDebug";
|
|
2
|
+
/**
|
|
3
|
+
* Represents an HTTP error response with a status code of 501 (Not Implemented).
|
|
4
|
+
* This class is used to standardize the structure of a "Not Implemented" error response,
|
|
5
|
+
* including the response body, headers, status, and status text.
|
|
6
|
+
*/
|
|
2
7
|
class NotImplemented {
|
|
3
8
|
body;
|
|
4
9
|
cause;
|
|
5
10
|
status = 501;
|
|
6
11
|
statusText;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of the `NotImplemented` class.
|
|
14
|
+
*
|
|
15
|
+
* @param message - A descriptive message explaining why the functionality is not implemented.
|
|
16
|
+
* @param cause - Optional additional information about the cause of the error.
|
|
17
|
+
*/
|
|
7
18
|
constructor(message, cause) {
|
|
8
19
|
this.body = { name: "NotImplemented", message: message };
|
|
9
20
|
this.statusText = message;
|
|
10
21
|
this.cause = cause ? JSON.stringify(cause) : undefined;
|
|
11
22
|
httpDebug("NotImplemented", this.body, this.cause);
|
|
12
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Converts the `NotImplemented` instance into a `Response` object with a JSON body.
|
|
26
|
+
* This method ensures the response has the appropriate headers, status, and status text.
|
|
27
|
+
*
|
|
28
|
+
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
29
|
+
*/
|
|
13
30
|
toResponse() {
|
|
14
31
|
const responseInit = {
|
|
15
32
|
headers: { "Content-Type": "application/json" },
|
|
@@ -18,6 +35,12 @@ class NotImplemented {
|
|
|
18
35
|
};
|
|
19
36
|
return new Response(JSON.stringify(this.body), responseInit);
|
|
20
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Converts the `NotImplemented` instance into a `Response` object using the `Response.json` method.
|
|
40
|
+
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
41
|
+
*
|
|
42
|
+
* @returns A `Response` object with the JSON body and response metadata.
|
|
43
|
+
*/
|
|
21
44
|
toJson() {
|
|
22
45
|
const responseInit = {
|
|
23
46
|
status: this.status,
|
|
@@ -1,10 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an HTTP error response with a status code of 500 (Internal Server Error).
|
|
3
|
+
* This class is used to standardize the structure of a "Server Error" response,
|
|
4
|
+
* including the response body, headers, status, and status text.
|
|
5
|
+
*/
|
|
1
6
|
declare class ServerError {
|
|
2
7
|
body: any;
|
|
3
8
|
cause?: any;
|
|
4
9
|
status: number;
|
|
5
10
|
statusText: string;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of the `ServerError` class.
|
|
13
|
+
*
|
|
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.
|
|
16
|
+
*/
|
|
6
17
|
constructor(message: string, cause?: any);
|
|
18
|
+
/**
|
|
19
|
+
* Converts the `ServerError` instance into a `Response` object with a JSON body.
|
|
20
|
+
* This method ensures the response has the appropriate headers, status, and status text.
|
|
21
|
+
*
|
|
22
|
+
* @returns A `Response` object with the serialized JSON body and response metadata.
|
|
23
|
+
*/
|
|
7
24
|
toResponse(): Response;
|
|
25
|
+
/**
|
|
26
|
+
* Converts the `ServerError` instance into a `Response` object using the `Response.json` method.
|
|
27
|
+
* This method is an alternative to `toResponse` for generating JSON error responses.
|
|
28
|
+
*
|
|
29
|
+
* @returns A `Response` object with the JSON body and response metadata.
|
|
30
|
+
*/
|
|
8
31
|
toJson(): Response;
|
|
9
32
|
}
|
|
10
33
|
export { ServerError };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverError.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/serverError.ts"],"names":[],"mappings":"AAEA,cAAM,WAAW;IACf,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"serverError.d.ts","sourceRoot":"","sources":["../../../src/http/badResponses/serverError.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,cAAM,WAAW;IACf,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,MAAM,CAAO;IACrB,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;OAKG;gBAES,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC;;;;;OAKG;IAEH,UAAU,IAAI,QAAQ;IAUtB;;;;;OAKG;IAEH,MAAM,IAAI,QAAQ;CAQnB;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|