@arkyn/server 3.0.1-beta.7 → 3.0.1-beta.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +368 -65
- package/dist/api/arkynLogRequest.d.ts +1 -1
- package/dist/api/arkynLogRequest.d.ts.map +1 -1
- package/dist/api/arkynLogRequest.js +14 -13
- package/dist/api/makeRequest.d.ts +1 -1
- package/dist/api/makeRequest.d.ts.map +1 -1
- package/dist/api/makeRequest.js +9 -8
- package/dist/bundle.js +1216 -0
- package/dist/bundle.umd.cjs +10 -0
- package/dist/http/badResponses/_badResponse.d.ts +11 -0
- package/dist/http/badResponses/_badResponse.d.ts.map +1 -0
- package/dist/http/badResponses/_badResponse.js +20 -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 +9 -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 +9 -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 +9 -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 +9 -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 +9 -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 +9 -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 +9 -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 +9 -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 +9 -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 +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/{config/apiInstance.d.ts → services/apiService.d.ts} +25 -21
- package/dist/services/apiService.d.ts.map +1 -0
- package/dist/{config/apiInstance.js → services/apiService.js} +45 -23
- package/dist/{config/arkynLogInstance.d.ts → services/arkynLogService.d.ts} +5 -5
- package/dist/services/arkynLogService.d.ts.map +1 -0
- package/dist/{config/arkynLogInstance.js → services/arkynLogService.js} +4 -5
- 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 +20 -0
- package/dist/services/formParse.d.ts +3 -3
- package/dist/services/formParse.d.ts.map +1 -1
- package/dist/services/formParse.js +7 -5
- package/dist/services/getCaller.d.ts.map +1 -1
- package/dist/services/getCaller.js +9 -14
- package/dist/services/measureRouteExecution.d.ts +3 -0
- package/dist/services/measureRouteExecution.d.ts.map +1 -0
- package/dist/services/measureRouteExecution.js +24 -0
- package/dist/services/schemaValidator.d.ts +3 -3
- package/dist/services/schemaValidator.d.ts.map +1 -1
- package/dist/services/schemaValidator.js +2 -4
- package/package.json +33 -18
- package/dist/config/apiInstance.d.ts.map +0 -1
- package/dist/config/arkynLogInstance.d.ts.map +0 -1
- package/dist/services/httpDebug.d.ts +0 -35
- package/dist/services/httpDebug.d.ts.map +0 -1
- package/dist/services/httpDebug.js +0 -52
- package/src/api/arkynLogRequest.ts +0 -118
- package/src/api/deleteRequest.ts +0 -22
- package/src/api/getRequest.ts +0 -20
- package/src/api/makeRequest.ts +0 -122
- package/src/api/patchRequest.ts +0 -22
- package/src/api/postRequest.ts +0 -22
- package/src/api/putRequest.ts +0 -22
- package/src/config/apiInstance.ts +0 -148
- package/src/config/arkynLogInstance.ts +0 -75
- package/src/http/badResponses/badGateway.ts +0 -63
- package/src/http/badResponses/badRequest.ts +0 -63
- package/src/http/badResponses/conflict.ts +0 -63
- package/src/http/badResponses/forbidden.ts +0 -63
- package/src/http/badResponses/notFound.ts +0 -63
- package/src/http/badResponses/notImplemented.ts +0 -63
- package/src/http/badResponses/serverError.ts +0 -63
- package/src/http/badResponses/unauthorized.ts +0 -63
- package/src/http/badResponses/unprocessableEntity.ts +0 -79
- package/src/http/successResponses/created.ts +0 -64
- package/src/http/successResponses/found.ts +0 -67
- package/src/http/successResponses/noContent.ts +0 -42
- package/src/http/successResponses/success.ts +0 -64
- package/src/http/successResponses/updated.ts +0 -64
- package/src/index.ts +0 -31
- package/src/mapper/arkynLogRequestMapper.ts +0 -73
- package/src/services/decodeErrorMessageFromRequest.ts +0 -36
- package/src/services/decodeRequestBody.ts +0 -43
- package/src/services/errorHandler.ts +0 -99
- package/src/services/formParse.ts +0 -83
- package/src/services/getCaller.ts +0 -82
- package/src/services/getScopedParams.ts +0 -43
- package/src/services/httpDebug.ts +0 -61
- package/src/services/schemaValidator.ts +0 -66
- package/src/types/ApiResponseDTO.ts +0 -19
- package/tsconfig.json +0 -21
- package/vitest.config.ts +0 -5
|
@@ -0,0 +1,54 @@
|
|
|
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 DebugService {
|
|
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 ignoreFiles: 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
|
+
* DebugService.setIgnoreFile("httpAdapter.ts");
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
static setIgnoreFile(file: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* Clears all configured ignore files.
|
|
41
|
+
*
|
|
42
|
+
* This method resets the ignore file configuration, allowing all files to be
|
|
43
|
+
* considered in stack trace analysis again.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* // Clear all ignore file configurations
|
|
48
|
+
* DebugService.clearIgnoreFiles();
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
static clearIgnoreFiles(): void;
|
|
52
|
+
}
|
|
53
|
+
export { DebugService };
|
|
54
|
+
//# sourceMappingURL=debugService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugService.d.ts","sourceRoot":"","sources":["../../src/services/debugService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,cAAM,YAAY;IAChB;;;OAGG;IACH,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,CAAM;IAElC;;;;;;;;;;;;;;OAcG;IAEH,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM;IAIjC;;;;;;;;;;;OAWG;IAEH,MAAM,CAAC,gBAAgB;CAGxB;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
class DebugService {
|
|
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 ignoreFiles = [];
|
|
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
|
+
* DebugService.setIgnoreFile("httpAdapter.ts");
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
static setIgnoreFile(file) {
|
|
39
|
+
this.ignoreFiles.push(file);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Clears all configured ignore files.
|
|
43
|
+
*
|
|
44
|
+
* This method resets the ignore file configuration, allowing all files to be
|
|
45
|
+
* considered in stack trace analysis again.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* // Clear all ignore file configurations
|
|
50
|
+
* DebugService.clearIgnoreFiles();
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
static clearIgnoreFiles() {
|
|
54
|
+
this.ignoreFiles = [];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export { DebugService };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flushDebugLogs.d.ts","sourceRoot":"","sources":["../../src/services/flushDebugLogs.ts"],"names":[],"mappings":"AAAA,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,iBAAS,cAAc,CAAC,KAAK,EAAE,mBAAmB,QAwBjD;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
function flushDebugLogs(props) {
|
|
2
|
+
const isDebugMode = process.env.NODE_ENV === "development" ||
|
|
3
|
+
process.env?.SHOW_ERRORS_IN_CONSOLE === "true";
|
|
4
|
+
if (isDebugMode) {
|
|
5
|
+
const reset = "\x1b[0m";
|
|
6
|
+
const colors = {
|
|
7
|
+
yellow: "\x1b[33m",
|
|
8
|
+
cyan: "\x1b[36m",
|
|
9
|
+
red: "\x1b[31m",
|
|
10
|
+
green: "\x1b[32m",
|
|
11
|
+
};
|
|
12
|
+
const debugName = `${colors[props.scheme]}[${props.name}]${reset}`;
|
|
13
|
+
let consoleData = `\n`;
|
|
14
|
+
props.debugs.forEach((debug) => {
|
|
15
|
+
consoleData += `${debugName} ${debug.trim()}\n`;
|
|
16
|
+
});
|
|
17
|
+
console.log(consoleData);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export { flushDebugLogs };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ZodType } from "zod";
|
|
2
2
|
type SuccessResponse<T extends FormParseProps> = {
|
|
3
3
|
success: true;
|
|
4
|
-
data: T[1] extends
|
|
4
|
+
data: T[1] extends ZodType<infer U> ? U : never;
|
|
5
5
|
};
|
|
6
6
|
type ErrorResponse = {
|
|
7
7
|
success: false;
|
|
@@ -14,7 +14,7 @@ type ErrorResponse = {
|
|
|
14
14
|
};
|
|
15
15
|
type FormParseProps = [formData: {
|
|
16
16
|
[k: string]: any;
|
|
17
|
-
}, schema:
|
|
17
|
+
}, schema: ZodType];
|
|
18
18
|
type FormParseReturnType<T extends FormParseProps> = SuccessResponse<T> | ErrorResponse;
|
|
19
19
|
/**
|
|
20
20
|
* Parses form data using a Zod schema and returns the result.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formParse.d.ts","sourceRoot":"","sources":["../../src/services/formParse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"formParse.d.ts","sourceRoot":"","sources":["../../src/services/formParse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC,KAAK,eAAe,CAAC,CAAC,SAAS,cAAc,IAAI;IAC/C,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;CACjD,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAChC,WAAW,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACtC,CAAC;AAEF,KAAK,cAAc,GAAG,CAAC,QAAQ,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAExE,KAAK,mBAAmB,CAAC,CAAC,SAAS,cAAc,IAC7C,eAAe,CAAC,CAAC,CAAC,GAClB,aAAa,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,iBAAS,SAAS,CAAC,CAAC,SAAS,cAAc,EAAE,CAC3C,QAAQ,EACR,MAAM,EACP,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAqB5B;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -39,10 +39,9 @@
|
|
|
39
39
|
function formParse([formData, schema,]) {
|
|
40
40
|
const zodResponse = schema.safeParse(formData);
|
|
41
41
|
if (zodResponse.success === false) {
|
|
42
|
-
const errorsObject = Object.fromEntries(zodResponse.error.
|
|
43
|
-
item.path.join("."),
|
|
44
|
-
|
|
45
|
-
]));
|
|
42
|
+
const errorsObject = Object.fromEntries(zodResponse.error.issues.map((item) => {
|
|
43
|
+
return [item.path.join("."), item.message];
|
|
44
|
+
}));
|
|
46
45
|
return {
|
|
47
46
|
success: zodResponse.success,
|
|
48
47
|
fieldErrors: errorsObject,
|
|
@@ -50,7 +49,10 @@ function formParse([formData, schema,]) {
|
|
|
50
49
|
};
|
|
51
50
|
}
|
|
52
51
|
else {
|
|
53
|
-
return {
|
|
52
|
+
return {
|
|
53
|
+
success: zodResponse.success,
|
|
54
|
+
data: zodResponse.data,
|
|
55
|
+
};
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
export { formParse };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCaller.d.ts","sourceRoot":"","sources":["../../src/services/getCaller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getCaller.d.ts","sourceRoot":"","sources":["../../src/services/getCaller.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AAEH,iBAAS,SAAS;;;EAiEjB;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
+
import { DebugService } from "./debugService";
|
|
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
|
-
|
|
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 ignoreFiles = DebugService.ignoreFiles;
|
|
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 (ignoreFiles.length > 0) {
|
|
27
|
+
while (callerIndex < stackLines.length &&
|
|
28
|
+
ignoreFiles.some((ignoreFile) => 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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measureRouteExecution.d.ts","sourceRoot":"","sources":["../../src/services/measureRouteExecution.ts"],"names":[],"mappings":"AAAA,iBAAS,qBAAqB,CAAC,CAAC,GAAG,OAAO,EACxC,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,IAEG,OAAO,GAAG,KAAG,OAAO,CAAC,CAAC,CAAC,CAyB9D;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function measureRouteExecution(handler) {
|
|
2
|
+
return async function measuredHandler(props) {
|
|
3
|
+
const startTime = performance.now();
|
|
4
|
+
try {
|
|
5
|
+
const result = await handler(props);
|
|
6
|
+
const url = new URL(props.request.url);
|
|
7
|
+
const endTime = performance.now();
|
|
8
|
+
const duration = (endTime - startTime).toFixed(2);
|
|
9
|
+
console.log({
|
|
10
|
+
domain: url.hostname,
|
|
11
|
+
pathname: url.pathname,
|
|
12
|
+
method: props.request.method,
|
|
13
|
+
duration,
|
|
14
|
+
});
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
const endTime = performance.now();
|
|
19
|
+
console.error("");
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export { measureRouteExecution };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare class SchemaValidator<T extends
|
|
1
|
+
import { ZodType, z } from "zod";
|
|
2
|
+
declare class SchemaValidator<T extends ZodType> {
|
|
3
3
|
readonly schema: T;
|
|
4
4
|
functionName: string;
|
|
5
5
|
callerInfo: string;
|
|
6
6
|
constructor(schema: T);
|
|
7
7
|
isValid(data: any): boolean;
|
|
8
|
-
safeValidate(data: any): z.
|
|
8
|
+
safeValidate(data: any): z.ZodSafeParseResult<z.infer<T>>;
|
|
9
9
|
validate(data: any): z.infer<T>;
|
|
10
10
|
formValidate(data: any, message?: string): z.infer<T>;
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaValidator.d.ts","sourceRoot":"","sources":["../../src/services/schemaValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"schemaValidator.d.ts","sourceRoot":"","sources":["../../src/services/schemaValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgBjC,cAAM,eAAe,CAAC,CAAC,SAAS,OAAO;IAIzB,QAAQ,CAAC,MAAM,EAAE,CAAC;IAH9B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;gBAEE,MAAM,EAAE,CAAC;IAM9B,OAAO,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO;IAI3B,YAAY,CAAC,IAAI,EAAE,GAAG,GAAG,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAIzD,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAQ/B,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;CAgBtD;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ZodType, z } from "zod";
|
|
2
2
|
import { ServerError } from "../http/badResponses/serverError";
|
|
3
3
|
import { UnprocessableEntity } from "../http/badResponses/unprocessableEntity";
|
|
4
4
|
import { formParse } from "./formParse";
|
|
5
5
|
import { getCaller } from "./getCaller";
|
|
6
|
-
import { httpDebug } from "./httpDebug";
|
|
7
6
|
function formatErrorMessage(error) {
|
|
8
7
|
const title = "Error validating:";
|
|
9
8
|
const lines = error.issues.map(({ path, message }) => `-> ${path.join(".")}: ${message}`);
|
|
@@ -36,14 +35,13 @@ class SchemaValidator {
|
|
|
36
35
|
formValidate(data, message) {
|
|
37
36
|
const formParsed = formParse([data, this.schema]);
|
|
38
37
|
if (!formParsed.success) {
|
|
39
|
-
httpDebug("UnprocessableEntity", formParsed);
|
|
40
38
|
const firstErrorKey = Object.keys(formParsed.fieldErrors)[0];
|
|
41
39
|
throw new UnprocessableEntity({
|
|
42
40
|
fields: formParsed.fields,
|
|
43
41
|
fieldErrors: formParsed.fieldErrors,
|
|
44
42
|
data: { scrollTo: firstErrorKey },
|
|
45
43
|
message,
|
|
46
|
-
}
|
|
44
|
+
});
|
|
47
45
|
}
|
|
48
46
|
return formParsed.data;
|
|
49
47
|
}
|
package/package.json
CHANGED
|
@@ -1,29 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkyn/server",
|
|
3
|
-
"version": "3.0.1-beta.
|
|
3
|
+
"version": "3.0.1-beta.71",
|
|
4
4
|
"author": "Arkyn | Lucas Gonçalves",
|
|
5
5
|
"main": "./dist/bundle.js",
|
|
6
|
-
"module": "./
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"zod": ">=3.24.2"
|
|
10
|
-
},
|
|
11
|
-
"devDependencies": {
|
|
12
|
-
"bun-types": "latest",
|
|
13
|
-
"vitest": "^3.1.1",
|
|
14
|
-
"typescript": "^5.8.3"
|
|
15
|
-
},
|
|
16
|
-
"peerDependencies": {
|
|
17
|
-
"@react-router/node": ">=7.6.0"
|
|
18
|
-
},
|
|
19
|
-
"description": "Server-side utilities for projects.",
|
|
6
|
+
"module": "./dist/bundle.js",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
20
9
|
"license": "Apache-2.0",
|
|
10
|
+
"description": "Comprehensive server-side utilities for building robust backend applications, featuring HTTP response helpers, error handlers, request utilities, and API configurations.",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"server",
|
|
13
|
+
"http",
|
|
14
|
+
"api",
|
|
15
|
+
"utilities",
|
|
16
|
+
"error-handling",
|
|
17
|
+
"validation",
|
|
18
|
+
"remix",
|
|
19
|
+
"typescript",
|
|
20
|
+
"zod"
|
|
21
|
+
],
|
|
22
|
+
"homepage": "https://docs.arkyn.dev/en/server/introduction",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/Lucas-Eduardo-Goncalves/arkyn.git",
|
|
26
|
+
"directory": "packages/server"
|
|
27
|
+
},
|
|
21
28
|
"scripts": {
|
|
22
29
|
"clean": "rm -rf dist",
|
|
23
|
-
"build": "
|
|
30
|
+
"build": "bunx vite build && tsc",
|
|
24
31
|
"test": "vitest --config vitest.config.ts",
|
|
25
32
|
"typecheck": "bunx tsc --project tsconfig.json --noEmit"
|
|
26
33
|
},
|
|
27
|
-
"
|
|
28
|
-
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@arkyn/shared": "*",
|
|
36
|
+
"zod": "^4.0.17"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"bun-types": "latest",
|
|
40
|
+
"vitest": "^3.2.4",
|
|
41
|
+
"typescript": "^5.9.2",
|
|
42
|
+
"vite": "^5.4.19"
|
|
43
|
+
}
|
|
29
44
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apiInstance.d.ts","sourceRoot":"","sources":["../../src/config/apiInstance.ts"],"names":[],"mappings":"AAMA,KAAK,0BAA0B,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF,KAAK,8BAA8B,GAAG;IACpC,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AAEH,cAAM,WAAW;IACf,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAC,CAAc;IAClC,OAAO,CAAC,SAAS,CAAC,CAAS;IAE3B;;;;;;OAMG;gBAES,KAAK,EAAE,0BAA0B;IAM7C;;;;OAIG;IAEH,OAAO,CAAC,WAAW;IAInB;;;;;OAKG;IAEH,OAAO,CAAC,eAAe;IAcvB;;;;;OAKG;IAEG,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,8BAA8B;IAM9D;;;;;OAKG;IAEG,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;IAO5D;;;;;OAKG;IAEG,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;IAO3D;;;;;OAKG;IAEG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;IAO7D;;;;;OAKG;IAEG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,2BAA2B;CAM/D;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arkynLogInstance.d.ts","sourceRoot":"","sources":["../../src/config/arkynLogInstance.ts"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GAAG;IACtB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF;;;;GAIG;AAEH,cAAM,gBAAgB;IACpB,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAmB;IAE9C;;;;;;;;;;OAUG;IAEH,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,mBAAmB;IAqBtD;;;;;OAKG;IACH,MAAM,CAAC,cAAc,IAAI,gBAAgB,GAAG,SAAS;IAIrD;;;OAGG;IAEH,MAAM,CAAC,gBAAgB;CAGxB;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Logs debug information to the console when in development mode or when the
|
|
3
|
-
* `SHOW_ERRORS_IN_CONSOLE` environment variable is set to "true".
|
|
4
|
-
*
|
|
5
|
-
* This function provides detailed information about the caller function,
|
|
6
|
-
* its location, and the provided body and cause, if any.
|
|
7
|
-
*
|
|
8
|
-
* @param name - A string representing the name or context of the debug log.
|
|
9
|
-
* @param body - The main content or data to be logged.
|
|
10
|
-
* @param cause - (Optional) Additional information or error cause to be logged.
|
|
11
|
-
*
|
|
12
|
-
* @remarks
|
|
13
|
-
* The debug logs are only displayed when the application is running in
|
|
14
|
-
* development mode (`NODE_ENV === "development"`) or when the
|
|
15
|
-
* `SHOW_ERRORS_IN_CONSOLE` environment variable is explicitly set to "true".
|
|
16
|
-
*
|
|
17
|
-
* The logs include:
|
|
18
|
-
* - The name of the debug context.
|
|
19
|
-
* - The caller function name and its location.
|
|
20
|
-
* - The provided body content.
|
|
21
|
-
* - The optional cause, if provided.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```typescript
|
|
25
|
-
* httpDebug("FetchUserData", { userId: 123 });
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* httpDebug("FetchUserDataError", { userId: 123 }, new Error("User not found"));
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
declare function httpDebug(name: string, body: any, cause?: any): void;
|
|
34
|
-
export { httpDebug };
|
|
35
|
-
//# sourceMappingURL=httpDebug.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,52 +0,0 @@
|
|
|
1
|
-
import { getCaller } from "../services/getCaller";
|
|
2
|
-
/**
|
|
3
|
-
* Logs debug information to the console when in development mode or when the
|
|
4
|
-
* `SHOW_ERRORS_IN_CONSOLE` environment variable is set to "true".
|
|
5
|
-
*
|
|
6
|
-
* This function provides detailed information about the caller function,
|
|
7
|
-
* its location, and the provided body and cause, if any.
|
|
8
|
-
*
|
|
9
|
-
* @param name - A string representing the name or context of the debug log.
|
|
10
|
-
* @param body - The main content or data to be logged.
|
|
11
|
-
* @param cause - (Optional) Additional information or error cause to be logged.
|
|
12
|
-
*
|
|
13
|
-
* @remarks
|
|
14
|
-
* The debug logs are only displayed when the application is running in
|
|
15
|
-
* development mode (`NODE_ENV === "development"`) or when the
|
|
16
|
-
* `SHOW_ERRORS_IN_CONSOLE` environment variable is explicitly set to "true".
|
|
17
|
-
*
|
|
18
|
-
* The logs include:
|
|
19
|
-
* - The name of the debug context.
|
|
20
|
-
* - The caller function name and its location.
|
|
21
|
-
* - The provided body content.
|
|
22
|
-
* - The optional cause, if provided.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```typescript
|
|
26
|
-
* httpDebug("FetchUserData", { userId: 123 });
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```typescript
|
|
31
|
-
* httpDebug("FetchUserDataError", { userId: 123 }, new Error("User not found"));
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
function httpDebug(name, body, cause) {
|
|
35
|
-
const isDebugMode = process.env.NODE_ENV === "development" ||
|
|
36
|
-
process.env?.SHOW_ERRORS_IN_CONSOLE === "true";
|
|
37
|
-
if (isDebugMode) {
|
|
38
|
-
const reset = "\x1b[0m";
|
|
39
|
-
const cyan = "\x1b[36m";
|
|
40
|
-
const debugName = `${cyan}[ARKYN-DEBUG]${reset}`;
|
|
41
|
-
const { callerInfo, functionName } = getCaller();
|
|
42
|
-
let consoleData = `${debugName} ${name} initialized\n`;
|
|
43
|
-
consoleData += `${debugName} Caller Function: ${functionName}\n`;
|
|
44
|
-
consoleData += `${debugName} Caller Location: ${callerInfo}\n`;
|
|
45
|
-
consoleData += `${debugName} Body: ${JSON.stringify(body, null, 2)}\n`;
|
|
46
|
-
if (cause) {
|
|
47
|
-
consoleData += `${debugName} Cause: ${JSON.stringify(cause, null, 2)}\n`;
|
|
48
|
-
}
|
|
49
|
-
console.log(consoleData);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
export { httpDebug };
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { ArkynLogInstance } from "../config/arkynLogInstance";
|
|
2
|
-
import { httpDebug } from "../services/httpDebug";
|
|
3
|
-
|
|
4
|
-
type ConfigProps = {
|
|
5
|
-
rawUrl: string;
|
|
6
|
-
status: number;
|
|
7
|
-
method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
8
|
-
token: string | null;
|
|
9
|
-
elapsedTime: number;
|
|
10
|
-
requestHeaders: Record<string, string>;
|
|
11
|
-
requestBody: Record<string, string>;
|
|
12
|
-
queryParams: Record<string, string>;
|
|
13
|
-
responseHeaders: Record<string, string>;
|
|
14
|
-
responseBody: Record<string, string>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Sends a request to the inbox flow API with the provided configuration.
|
|
19
|
-
*
|
|
20
|
-
* @param config - The configuration object for the request.
|
|
21
|
-
* @param config.rawUrl - The raw URL of the request.
|
|
22
|
-
* @param config.status - The HTTP status code associated with the request.
|
|
23
|
-
* @param config.method - The HTTP method used for the request. Can be "POST", "GET", "PUT", "DELETE", or "PATCH".
|
|
24
|
-
* @param config.token - The authentication token for the request.
|
|
25
|
-
* @param config.elapsedTime - The elapsed time for the request in milliseconds.
|
|
26
|
-
* @param config.requestHeaders - The headers sent with the request.
|
|
27
|
-
* @param config.requestBody - The body of the request, if applicable.
|
|
28
|
-
* @param config.queryParams - The query parameters for the request.
|
|
29
|
-
* @param config.responseHeaders - The headers received in the response.
|
|
30
|
-
* @param config.responseBody - The body of the response received.
|
|
31
|
-
*
|
|
32
|
-
* @remarks
|
|
33
|
-
* - This function retrieves the inbox flow configuration using `InboxFlowInstance.getInboxConfig()`.
|
|
34
|
-
* - If the configuration is not available, the function will return early without performing any action.
|
|
35
|
-
* - In a development environment (`NODE_ENV === "development"`), the function will also return early.
|
|
36
|
-
* - The request is sent as a POST request to the inbox API URL with the provided configuration details.
|
|
37
|
-
* - If an error occurs during the request, it will be logged using the `httpDebug` service.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```typescript
|
|
41
|
-
* const config = {
|
|
42
|
-
* rawUrl: "https://example.com/api/data",
|
|
43
|
-
* status: 200,
|
|
44
|
-
* method: "GET",
|
|
45
|
-
* token: "auth-token-123",
|
|
46
|
-
* elapsedTime: "150ms",
|
|
47
|
-
* requestHeaders: { "Accept": "application/json", "Authorization": "Bearer token123" },
|
|
48
|
-
* requestBody: {},
|
|
49
|
-
* queryParams: { "page": "1", "limit": "10" },
|
|
50
|
-
* responseHeaders: { "Content-Type": "application/json" },
|
|
51
|
-
* responseBody: { "data": "example response" }
|
|
52
|
-
* };
|
|
53
|
-
*
|
|
54
|
-
* await arkynLogRequest(config);
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
async function arkynLogRequest(config: ConfigProps) {
|
|
59
|
-
const arkynInstance = ArkynLogInstance.getArkynConfig();
|
|
60
|
-
console.log("arkynInstance", arkynInstance);
|
|
61
|
-
|
|
62
|
-
if (!arkynInstance) return;
|
|
63
|
-
|
|
64
|
-
console.log("dasd", arkynInstance);
|
|
65
|
-
|
|
66
|
-
const { arkynUserToken } = arkynInstance;
|
|
67
|
-
let arkynApiUrl = arkynInstance.arkynApiUrl;
|
|
68
|
-
arkynApiUrl.replace(":trafficSourceId", arkynInstance.arkynTrafficSourceId);
|
|
69
|
-
|
|
70
|
-
const {
|
|
71
|
-
elapsedTime,
|
|
72
|
-
method,
|
|
73
|
-
queryParams,
|
|
74
|
-
requestBody,
|
|
75
|
-
requestHeaders,
|
|
76
|
-
responseBody,
|
|
77
|
-
responseHeaders,
|
|
78
|
-
status,
|
|
79
|
-
token,
|
|
80
|
-
rawUrl,
|
|
81
|
-
} = config;
|
|
82
|
-
|
|
83
|
-
// if (process.env.NODE_ENV === "development") return;
|
|
84
|
-
|
|
85
|
-
try {
|
|
86
|
-
const url = new URL(rawUrl);
|
|
87
|
-
let protocol: "HTTPS" | "HTTP" = "HTTPS";
|
|
88
|
-
if (url.protocol === "http:") protocol = "HTTP";
|
|
89
|
-
|
|
90
|
-
const body = JSON.stringify({
|
|
91
|
-
domainUrl: url.protocol + "//" + url.host,
|
|
92
|
-
pathnameUrl: url.pathname,
|
|
93
|
-
status,
|
|
94
|
-
protocol,
|
|
95
|
-
method,
|
|
96
|
-
trafficUserId: null,
|
|
97
|
-
elapsedTime,
|
|
98
|
-
requestHeaders,
|
|
99
|
-
requestBody,
|
|
100
|
-
queryParams,
|
|
101
|
-
responseHeaders,
|
|
102
|
-
responseBody,
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
await fetch(arkynApiUrl, {
|
|
106
|
-
method: "POST",
|
|
107
|
-
body,
|
|
108
|
-
headers: {
|
|
109
|
-
"Content-Type": "application/json",
|
|
110
|
-
Authorization: `Bearer ${arkynUserToken}`,
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
} catch (err) {
|
|
114
|
-
httpDebug("arkyn log error", "Error sending request", err);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export { arkynLogRequest };
|