@dnax/core 0.5.8 → 0.6.0
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/app/hono.ts +10 -3
- package/package.json +1 -1
package/app/hono.ts
CHANGED
|
@@ -62,6 +62,12 @@ function HonoInstance(): typeof app {
|
|
|
62
62
|
}
|
|
63
63
|
if (typeof Cfg?.server?.logger == "boolean" && Cfg?.server?.logger) {
|
|
64
64
|
app.use(async (c, next) => {
|
|
65
|
+
let ip =
|
|
66
|
+
c.req.raw.headers?.get("CF-Connecting-IP") ||
|
|
67
|
+
c.req.raw.headers?.get("x-forwarded-for") ||
|
|
68
|
+
c.req.raw.headers?.get("x-real-ip");
|
|
69
|
+
const origin =
|
|
70
|
+
c.req?.header("Origin") || c.req.raw?.headers?.get("Origin") || "";
|
|
65
71
|
const info = getConnInfo(c);
|
|
66
72
|
if (c.req.method == "OPTIONS") return await next();
|
|
67
73
|
const start = Date.now();
|
|
@@ -69,7 +75,7 @@ function HonoInstance(): typeof app {
|
|
|
69
75
|
c.req.query() as Q;
|
|
70
76
|
// Log the incoming request
|
|
71
77
|
console.log(
|
|
72
|
-
`<-- ${info.remote.address} | ${c.req.method.gray} ${
|
|
78
|
+
`<-- ${ip || info.remote.address} ${origin} | ${c.req.method.gray} ${
|
|
73
79
|
c.req.path?.gray
|
|
74
80
|
} -C ${colors.blue(`${collection || ""}`)} -A ${
|
|
75
81
|
action?.gray || ""
|
|
@@ -82,11 +88,11 @@ function HonoInstance(): typeof app {
|
|
|
82
88
|
// Calculate the duration of the request processing
|
|
83
89
|
const duration = Date.now() - start;
|
|
84
90
|
console.log(
|
|
85
|
-
`--> ${info.remote.address} | ${c.req.method.gray} ${
|
|
91
|
+
`--> ${ip || info.remote.address} ${origin} | ${c.req.method.gray} ${
|
|
86
92
|
c.req.path?.gray
|
|
87
93
|
} -C ${colors.blue(`${collection || ""}`)} -A ${
|
|
88
94
|
action?.gray || ""
|
|
89
|
-
} -Sn ${name?.gray || ""}
|
|
95
|
+
} -Sn ${name?.gray || ""} -s ${c.res.status} -d ${colors.green(
|
|
90
96
|
`(${duration}ms)`
|
|
91
97
|
)} -t ${moment().format("YYYY-DD-MM:HH:mm:ss").gray} \n`
|
|
92
98
|
);
|
|
@@ -121,6 +127,7 @@ function HonoInstance(): typeof app {
|
|
|
121
127
|
c.set("_STUDIO_SECRET_KEY_", secretKeyStudio);
|
|
122
128
|
c.set("isStudio", isStudio(secretKeyStudio));
|
|
123
129
|
}
|
|
130
|
+
|
|
124
131
|
let _v = {
|
|
125
132
|
token: token || null,
|
|
126
133
|
ip:
|