@arkyn/server 3.0.1-beta.33 → 3.0.1-beta.34

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/index.d.ts CHANGED
@@ -20,6 +20,6 @@ export { errorHandler } from "./services/errorHandler";
20
20
  export { formParse } from "./services/formParse";
21
21
  export { getCaller } from "./services/getCaller";
22
22
  export { getScopedParams } from "./services/getScopedParams";
23
- export { httpDebug } from "./services/httpDebug";
23
+ export { httpDebug, HttpDebugService } from "./services/httpDebug";
24
24
  export { SchemaValidator } from "./services/schemaValidator";
25
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAG7D,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;AAG9E,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,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O,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,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -24,5 +24,5 @@ export { errorHandler } from "./services/errorHandler";
24
24
  export { formParse } from "./services/formParse";
25
25
  export { getCaller } from "./services/getCaller";
26
26
  export { getScopedParams } from "./services/getScopedParams";
27
- export { httpDebug } from "./services/httpDebug";
27
+ export { httpDebug, HttpDebugService } from "./services/httpDebug";
28
28
  export { SchemaValidator } from "./services/schemaValidator";
@@ -1 +1 @@
1
- {"version":3,"file":"getCaller.d.ts","sourceRoot":"","sources":["../../src/services/getCaller.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,iBAAS,SAAS;;;EAkEjB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"getCaller.d.ts","sourceRoot":"","sources":["../../src/services/getCaller.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AAEH,iBAAS,SAAS;;;EA+DjB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import path from "path";
2
+ import { HttpDebugService } from "./httpDebug";
2
3
  /**
3
4
  * Retrieves information about the caller of the current function.
4
5
  *
@@ -15,51 +16,45 @@ function getCaller() {
15
16
  const err = new Error();
16
17
  const stack = err.stack || "";
17
18
  const stackLines = stack.split("\n").map((line) => line.trim());
18
- // The first line is the error message
19
- // The second line is this function (getCaller)
20
- // The third line should be the direct caller
21
- // We start from 2 because indexes are zero-based
19
+ const ignoreFile = HttpDebugService.ignoreFile;
22
20
  let callerIndex = 2;
23
- // Ignore internal or infrastructure lines if necessary
24
21
  while (callerIndex < stackLines.length &&
25
22
  (stackLines[callerIndex].includes("node:internal") ||
26
23
  stackLines[callerIndex].includes("/node_modules/"))) {
27
24
  callerIndex++;
28
25
  }
26
+ if (ignoreFile) {
27
+ while (callerIndex < stackLines.length &&
28
+ stackLines[callerIndex].includes(ignoreFile)) {
29
+ callerIndex++;
30
+ }
31
+ }
29
32
  const callerLine = stackLines[callerIndex] || "";
30
33
  let functionName = "Unknown function";
31
34
  let callerInfo = "Unknown caller";
32
- // Default for named functions: "at functionName (file:line:column)"
33
35
  const namedFunctionMatch = callerLine.match(/at\s+([^(\s]+)\s+\(([^)]+)\)/);
34
36
  if (namedFunctionMatch) {
35
37
  functionName = namedFunctionMatch[1];
36
38
  callerInfo = namedFunctionMatch[2];
37
39
  }
38
- // Default for anonymous functions or methods: "at file:line:column"
39
40
  else {
40
41
  const anonymousFunctionMatch = callerLine.match(/at\s+(.+)/);
41
42
  if (anonymousFunctionMatch) {
42
43
  callerInfo = anonymousFunctionMatch[1];
43
- // Tenta extrair nome da função de padrões como Object.method ou Class.method
44
44
  const objectMethodMatch = callerInfo.match(/at\s+([^(\s]+)\s+/);
45
45
  if (objectMethodMatch && objectMethodMatch[1] !== "new") {
46
46
  functionName = objectMethodMatch[1];
47
47
  }
48
48
  }
49
49
  }
50
- // Handles file paths
51
50
  if (callerInfo.includes("(")) {
52
51
  callerInfo = callerInfo.substring(callerInfo.indexOf("(") + 1, callerInfo.lastIndexOf(")"));
53
52
  }
54
- // Remove the line:column part of the file path
55
53
  callerInfo = callerInfo.split(":").slice(0, -2).join(":");
56
- // Make the path relative to the project
57
54
  try {
58
55
  callerInfo = path.relative(projectRoot, callerInfo);
59
56
  }
60
- catch (e) {
61
- // If it fails to relativize, use the original path
62
- }
57
+ catch (e) { }
63
58
  return { functionName, callerInfo };
64
59
  }
65
60
  export { getCaller };
@@ -1,3 +1,7 @@
1
+ declare class HttpDebugService {
2
+ static ignoreFile?: string;
3
+ static setIgnoreFile(file: string): void;
4
+ }
1
5
  /**
2
6
  * Logs debug information to the console when in development mode or when the
3
7
  * `SHOW_ERRORS_IN_CONSOLE` environment variable is set to "true".
@@ -31,5 +35,5 @@
31
35
  * ```
32
36
  */
33
37
  declare function httpDebug(name: string, body: any, cause?: any): void;
34
- export { httpDebug };
38
+ export { httpDebug, HttpDebugService };
35
39
  //# sourceMappingURL=httpDebug.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"httpDebug.d.ts","sourceRoot":"","sources":["../../src/services/httpDebug.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,iBAAS,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG,QAuBtD;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"httpDebug.d.ts","sourceRoot":"","sources":["../../src/services/httpDebug.ts"],"names":[],"mappings":"AAEA,cAAM,gBAAgB;IACpB,MAAM,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE3B,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,4 +1,10 @@
1
1
  import { getCaller } from "../services/getCaller";
2
+ class HttpDebugService {
3
+ static ignoreFile;
4
+ static setIgnoreFile(file) {
5
+ this.ignoreFile = file;
6
+ }
7
+ }
2
8
  /**
3
9
  * Logs debug information to the console when in development mode or when the
4
10
  * `SHOW_ERRORS_IN_CONSOLE` environment variable is set to "true".
@@ -49,4 +55,4 @@ function httpDebug(name, body, cause) {
49
55
  console.log(consoleData);
50
56
  }
51
57
  }
52
- export { httpDebug };
58
+ export { httpDebug, HttpDebugService };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/server",
3
- "version": "3.0.1-beta.33",
3
+ "version": "3.0.1-beta.34",
4
4
  "author": "Arkyn | Lucas Gonçalves",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./src/index.ts",
package/src/index.ts CHANGED
@@ -27,5 +27,5 @@ export { errorHandler } from "./services/errorHandler";
27
27
  export { formParse } from "./services/formParse";
28
28
  export { getCaller } from "./services/getCaller";
29
29
  export { getScopedParams } from "./services/getScopedParams";
30
- export { httpDebug } from "./services/httpDebug";
30
+ export { httpDebug, HttpDebugService } from "./services/httpDebug";
31
31
  export { SchemaValidator } from "./services/schemaValidator";
@@ -1,4 +1,5 @@
1
1
  import path from "path";
2
+ import { HttpDebugService } from "./httpDebug";
2
3
 
3
4
  /**
4
5
  * Retrieves information about the caller of the current function.
@@ -11,6 +12,7 @@ import path from "path";
11
12
  * - `functionName`: The name of the function that called the current function, or "Unknown function" if it cannot be determined.
12
13
  * - `callerInfo`: The file path of the caller relative to the project root, or "Unknown caller" if it cannot be determined.
13
14
  */
15
+
14
16
  function getCaller() {
15
17
  const projectRoot = process.cwd();
16
18
 
@@ -18,13 +20,10 @@ function getCaller() {
18
20
  const stack = err.stack || "";
19
21
  const stackLines = stack.split("\n").map((line) => line.trim());
20
22
 
21
- // The first line is the error message
22
- // The second line is this function (getCaller)
23
- // The third line should be the direct caller
24
- // We start from 2 because indexes are zero-based
23
+ const ignoreFile = HttpDebugService.ignoreFile;
24
+
25
25
  let callerIndex = 2;
26
26
 
27
- // Ignore internal or infrastructure lines if necessary
28
27
  while (
29
28
  callerIndex < stackLines.length &&
30
29
  (stackLines[callerIndex].includes("node:internal") ||
@@ -33,24 +32,29 @@ function getCaller() {
33
32
  callerIndex++;
34
33
  }
35
34
 
35
+ if (ignoreFile) {
36
+ while (
37
+ callerIndex < stackLines.length &&
38
+ stackLines[callerIndex].includes(ignoreFile)
39
+ ) {
40
+ callerIndex++;
41
+ }
42
+ }
43
+
36
44
  const callerLine = stackLines[callerIndex] || "";
37
45
 
38
46
  let functionName = "Unknown function";
39
47
  let callerInfo = "Unknown caller";
40
48
 
41
- // Default for named functions: "at functionName (file:line:column)"
42
49
  const namedFunctionMatch = callerLine.match(/at\s+([^(\s]+)\s+\(([^)]+)\)/);
43
50
  if (namedFunctionMatch) {
44
51
  functionName = namedFunctionMatch[1];
45
52
  callerInfo = namedFunctionMatch[2];
46
- }
47
- // Default for anonymous functions or methods: "at file:line:column"
48
- else {
53
+ } else {
49
54
  const anonymousFunctionMatch = callerLine.match(/at\s+(.+)/);
50
55
  if (anonymousFunctionMatch) {
51
56
  callerInfo = anonymousFunctionMatch[1];
52
57
 
53
- // Tenta extrair nome da função de padrões como Object.method ou Class.method
54
58
  const objectMethodMatch = callerInfo.match(/at\s+([^(\s]+)\s+/);
55
59
  if (objectMethodMatch && objectMethodMatch[1] !== "new") {
56
60
  functionName = objectMethodMatch[1];
@@ -58,7 +62,6 @@ function getCaller() {
58
62
  }
59
63
  }
60
64
 
61
- // Handles file paths
62
65
  if (callerInfo.includes("(")) {
63
66
  callerInfo = callerInfo.substring(
64
67
  callerInfo.indexOf("(") + 1,
@@ -66,15 +69,11 @@ function getCaller() {
66
69
  );
67
70
  }
68
71
 
69
- // Remove the line:column part of the file path
70
72
  callerInfo = callerInfo.split(":").slice(0, -2).join(":");
71
73
 
72
- // Make the path relative to the project
73
74
  try {
74
75
  callerInfo = path.relative(projectRoot, callerInfo);
75
- } catch (e) {
76
- // If it fails to relativize, use the original path
77
- }
76
+ } catch (e) {}
78
77
 
79
78
  return { functionName, callerInfo };
80
79
  }
@@ -1,5 +1,13 @@
1
1
  import { getCaller } from "../services/getCaller";
2
2
 
3
+ class HttpDebugService {
4
+ static ignoreFile?: string;
5
+
6
+ static setIgnoreFile(file: string) {
7
+ this.ignoreFile = file;
8
+ }
9
+ }
10
+
3
11
  /**
4
12
  * Logs debug information to the console when in development mode or when the
5
13
  * `SHOW_ERRORS_IN_CONSOLE` environment variable is set to "true".
@@ -58,4 +66,4 @@ function httpDebug(name: string, body: any, cause?: any) {
58
66
  }
59
67
  }
60
68
 
61
- export { httpDebug };
69
+ export { httpDebug, HttpDebugService };