@arkyn/server 3.0.1-beta.61 → 3.0.1-beta.63
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/api/arkynLogRequest.d.ts.map +1 -1
- package/dist/api/arkynLogRequest.js +8 -3
- package/dist/api/makeRequest.d.ts.map +1 -1
- package/dist/api/makeRequest.js +6 -2
- package/dist/bundle.js +484 -393
- package/dist/bundle.umd.cjs +14 -8
- package/dist/http/badResponses/_badResponse.d.ts +22 -0
- package/dist/http/badResponses/_badResponse.d.ts.map +1 -0
- package/dist/http/badResponses/_badResponse.js +33 -0
- package/dist/http/badResponses/badGateway.d.ts +2 -1
- package/dist/http/badResponses/badGateway.d.ts.map +1 -1
- package/dist/http/badResponses/badGateway.js +4 -3
- package/dist/http/badResponses/badRequest.d.ts +2 -1
- package/dist/http/badResponses/badRequest.d.ts.map +1 -1
- package/dist/http/badResponses/badRequest.js +4 -3
- package/dist/http/badResponses/conflict.d.ts +2 -1
- package/dist/http/badResponses/conflict.d.ts.map +1 -1
- package/dist/http/badResponses/conflict.js +4 -3
- package/dist/http/badResponses/forbidden.d.ts +2 -1
- package/dist/http/badResponses/forbidden.d.ts.map +1 -1
- package/dist/http/badResponses/forbidden.js +4 -3
- package/dist/http/badResponses/notFound.d.ts +2 -1
- package/dist/http/badResponses/notFound.d.ts.map +1 -1
- package/dist/http/badResponses/notFound.js +4 -3
- package/dist/http/badResponses/notImplemented.d.ts +2 -1
- package/dist/http/badResponses/notImplemented.d.ts.map +1 -1
- package/dist/http/badResponses/notImplemented.js +4 -3
- package/dist/http/badResponses/serverError.d.ts +2 -1
- package/dist/http/badResponses/serverError.d.ts.map +1 -1
- package/dist/http/badResponses/serverError.js +4 -3
- package/dist/http/badResponses/unauthorized.d.ts +2 -1
- package/dist/http/badResponses/unauthorized.d.ts.map +1 -1
- package/dist/http/badResponses/unauthorized.js +4 -3
- package/dist/http/badResponses/unprocessableEntity.d.ts +3 -2
- package/dist/http/badResponses/unprocessableEntity.d.ts.map +1 -1
- package/dist/http/badResponses/unprocessableEntity.js +5 -4
- package/dist/http/successResponses/_successResponse.d.ts +22 -0
- package/dist/http/successResponses/_successResponse.d.ts.map +1 -0
- package/dist/http/successResponses/_successResponse.js +37 -0
- package/dist/http/successResponses/created.d.ts +2 -1
- package/dist/http/successResponses/created.d.ts.map +1 -1
- package/dist/http/successResponses/created.js +4 -1
- package/dist/http/successResponses/found.d.ts +2 -1
- package/dist/http/successResponses/found.d.ts.map +1 -1
- package/dist/http/successResponses/found.js +4 -1
- package/dist/http/successResponses/noContent.d.ts +2 -1
- package/dist/http/successResponses/noContent.d.ts.map +1 -1
- package/dist/http/successResponses/noContent.js +4 -1
- package/dist/http/successResponses/success.d.ts +2 -1
- package/dist/http/successResponses/success.d.ts.map +1 -1
- package/dist/http/successResponses/success.js +4 -1
- package/dist/http/successResponses/updated.d.ts +2 -1
- package/dist/http/successResponses/updated.d.ts.map +1 -1
- package/dist/http/successResponses/updated.js +4 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/services/apiService.d.ts.map +1 -1
- package/dist/services/apiService.js +8 -8
- package/dist/services/debugService.d.ts +54 -0
- package/dist/services/debugService.d.ts.map +1 -0
- package/dist/services/debugService.js +57 -0
- package/dist/services/flushDebugLogs.d.ts +8 -0
- package/dist/services/flushDebugLogs.d.ts.map +1 -0
- package/dist/services/flushDebugLogs.js +21 -0
- package/dist/services/formParse.d.ts.map +1 -1
- package/dist/services/formParse.js +0 -1
- package/dist/services/getCaller.d.ts.map +1 -1
- package/dist/services/getCaller.js +4 -4
- package/dist/services/schemaValidator.d.ts.map +1 -1
- package/dist/services/schemaValidator.js +1 -3
- package/package.json +1 -1
- package/dist/services/httpDebug.d.ts +0 -74
- package/dist/services/httpDebug.d.ts.map +0 -1
- package/dist/services/httpDebug.js +0 -93
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Service for managing HTTP debug configuration and behavior.
|
|
3
|
-
*
|
|
4
|
-
* This service provides functionality to configure how the `getCaller` function
|
|
5
|
-
* identifies the actual caller in the stack trace by allowing specific files
|
|
6
|
-
* to be ignored during stack trace analysis.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* // Configure to ignore httpAdapter.ts in stack traces
|
|
11
|
-
* HttpDebugService.setIgnoreFile("httpAdapter.ts");
|
|
12
|
-
*
|
|
13
|
-
* // Now when httpDebug is called from within httpAdapter.ts,
|
|
14
|
-
* // it will show the actual caller (e.g., cart.ts) instead
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
declare class HttpDebugService {
|
|
18
|
-
/**
|
|
19
|
-
* The name of the file to ignore when analyzing the stack trace.
|
|
20
|
-
* When set, the `getCaller` function will skip stack frames containing this file name.
|
|
21
|
-
*/
|
|
22
|
-
static ignoreFile?: string;
|
|
23
|
-
/**
|
|
24
|
-
* Sets the file name to be ignored during stack trace analysis.
|
|
25
|
-
*
|
|
26
|
-
* This method configures the debug service to skip specific files when
|
|
27
|
-
* determining the actual caller of a function. This is useful when you have
|
|
28
|
-
* adapter or wrapper functions that you want to be transparent in the debug output.
|
|
29
|
-
*
|
|
30
|
-
* @param file - The name of the file to ignore in stack traces (e.g., "httpAdapter.ts")
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```typescript
|
|
34
|
-
* // Ignore the HTTP adapter file so debug shows the actual business logic caller
|
|
35
|
-
* HttpDebugService.setIgnoreFile("httpAdapter.ts");
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
static setIgnoreFile(file: string): void;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Logs debug information to the console when in development mode or when the
|
|
42
|
-
* `SHOW_ERRORS_IN_CONSOLE` environment variable is set to "true".
|
|
43
|
-
*
|
|
44
|
-
* This function provides detailed information about the caller function,
|
|
45
|
-
* its location, and the provided body and cause, if any.
|
|
46
|
-
*
|
|
47
|
-
* @param name - A string representing the name or context of the debug log.
|
|
48
|
-
* @param body - The main content or data to be logged.
|
|
49
|
-
* @param cause - (Optional) Additional information or error cause to be logged.
|
|
50
|
-
*
|
|
51
|
-
* @remarks
|
|
52
|
-
* The debug logs are only displayed when the application is running in
|
|
53
|
-
* development mode (`NODE_ENV === "development"`) or when the
|
|
54
|
-
* `SHOW_ERRORS_IN_CONSOLE` environment variable is explicitly set to "true".
|
|
55
|
-
*
|
|
56
|
-
* The logs include:
|
|
57
|
-
* - The name of the debug context.
|
|
58
|
-
* - The caller function name and its location.
|
|
59
|
-
* - The provided body content.
|
|
60
|
-
* - The optional cause, if provided.
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```typescript
|
|
64
|
-
* httpDebug("FetchUserData", { userId: 123 });
|
|
65
|
-
* ```
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```typescript
|
|
69
|
-
* httpDebug("FetchUserDataError", { userId: 123 }, new Error("User not found"));
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
declare function httpDebug(name: string, body: any, cause?: any): void;
|
|
73
|
-
export { httpDebug, HttpDebugService };
|
|
74
|
-
//# sourceMappingURL=httpDebug.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"httpDebug.d.ts","sourceRoot":"","sources":["../../src/services/httpDebug.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,cAAM,gBAAgB;IACpB;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM;CAGlC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,iBAAS,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG,QAuBtD;AAED,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { getCaller } from "../services/getCaller";
|
|
2
|
-
/**
|
|
3
|
-
* Service for managing HTTP debug configuration and behavior.
|
|
4
|
-
*
|
|
5
|
-
* This service provides functionality to configure how the `getCaller` function
|
|
6
|
-
* identifies the actual caller in the stack trace by allowing specific files
|
|
7
|
-
* to be ignored during stack trace analysis.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* // Configure to ignore httpAdapter.ts in stack traces
|
|
12
|
-
* HttpDebugService.setIgnoreFile("httpAdapter.ts");
|
|
13
|
-
*
|
|
14
|
-
* // Now when httpDebug is called from within httpAdapter.ts,
|
|
15
|
-
* // it will show the actual caller (e.g., cart.ts) instead
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
class HttpDebugService {
|
|
19
|
-
/**
|
|
20
|
-
* The name of the file to ignore when analyzing the stack trace.
|
|
21
|
-
* When set, the `getCaller` function will skip stack frames containing this file name.
|
|
22
|
-
*/
|
|
23
|
-
static ignoreFile;
|
|
24
|
-
/**
|
|
25
|
-
* Sets the file name to be ignored during stack trace analysis.
|
|
26
|
-
*
|
|
27
|
-
* This method configures the debug service to skip specific files when
|
|
28
|
-
* determining the actual caller of a function. This is useful when you have
|
|
29
|
-
* adapter or wrapper functions that you want to be transparent in the debug output.
|
|
30
|
-
*
|
|
31
|
-
* @param file - The name of the file to ignore in stack traces (e.g., "httpAdapter.ts")
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* // Ignore the HTTP adapter file so debug shows the actual business logic caller
|
|
36
|
-
* HttpDebugService.setIgnoreFile("httpAdapter.ts");
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
static setIgnoreFile(file) {
|
|
40
|
-
this.ignoreFile = file;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Logs debug information to the console when in development mode or when the
|
|
45
|
-
* `SHOW_ERRORS_IN_CONSOLE` environment variable is set to "true".
|
|
46
|
-
*
|
|
47
|
-
* This function provides detailed information about the caller function,
|
|
48
|
-
* its location, and the provided body and cause, if any.
|
|
49
|
-
*
|
|
50
|
-
* @param name - A string representing the name or context of the debug log.
|
|
51
|
-
* @param body - The main content or data to be logged.
|
|
52
|
-
* @param cause - (Optional) Additional information or error cause to be logged.
|
|
53
|
-
*
|
|
54
|
-
* @remarks
|
|
55
|
-
* The debug logs are only displayed when the application is running in
|
|
56
|
-
* development mode (`NODE_ENV === "development"`) or when the
|
|
57
|
-
* `SHOW_ERRORS_IN_CONSOLE` environment variable is explicitly set to "true".
|
|
58
|
-
*
|
|
59
|
-
* The logs include:
|
|
60
|
-
* - The name of the debug context.
|
|
61
|
-
* - The caller function name and its location.
|
|
62
|
-
* - The provided body content.
|
|
63
|
-
* - The optional cause, if provided.
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```typescript
|
|
67
|
-
* httpDebug("FetchUserData", { userId: 123 });
|
|
68
|
-
* ```
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```typescript
|
|
72
|
-
* httpDebug("FetchUserDataError", { userId: 123 }, new Error("User not found"));
|
|
73
|
-
* ```
|
|
74
|
-
*/
|
|
75
|
-
function httpDebug(name, body, cause) {
|
|
76
|
-
const isDebugMode = process.env.NODE_ENV === "development" ||
|
|
77
|
-
process.env?.SHOW_ERRORS_IN_CONSOLE === "true";
|
|
78
|
-
if (isDebugMode) {
|
|
79
|
-
const reset = "\x1b[0m";
|
|
80
|
-
const cyan = "\x1b[36m";
|
|
81
|
-
const debugName = `${cyan}[ARKYN-DEBUG]${reset}`;
|
|
82
|
-
const { callerInfo, functionName } = getCaller();
|
|
83
|
-
let consoleData = `${debugName} ${name} initialized\n`;
|
|
84
|
-
consoleData += `${debugName} Caller Function: ${functionName}\n`;
|
|
85
|
-
consoleData += `${debugName} Caller Location: ${callerInfo}\n`;
|
|
86
|
-
consoleData += `${debugName} Body: ${JSON.stringify(body, null, 2)}\n`;
|
|
87
|
-
if (cause) {
|
|
88
|
-
consoleData += `${debugName} Cause: ${JSON.stringify(cause, null, 2)}\n`;
|
|
89
|
-
}
|
|
90
|
-
console.log(consoleData);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
export { httpDebug, HttpDebugService };
|