@dnax/core 0.15.2 → 0.15.3
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 +0 -74
- package/lib/socket/instance.ts +0 -1
- package/package.json +1 -1
- package/types/index.ts +11 -4
package/app/hono.ts
CHANGED
|
@@ -52,78 +52,6 @@ function HonoInstance(): typeof app {
|
|
|
52
52
|
})
|
|
53
53
|
);
|
|
54
54
|
|
|
55
|
-
if (Cfg?.server?.logger) {
|
|
56
|
-
if (typeof Cfg?.server?.logger == "function" && Cfg?.server?.logger) {
|
|
57
|
-
app.use(async (c, next) => {
|
|
58
|
-
const start = Date.now();
|
|
59
|
-
const { action, collection, cleanDeep, useCache } = c.req.query() as Q;
|
|
60
|
-
Cfg.server.logger(c, {
|
|
61
|
-
mode: "incomming",
|
|
62
|
-
start: start,
|
|
63
|
-
action: action,
|
|
64
|
-
collection: collection,
|
|
65
|
-
cleanDeep: cleanDeep,
|
|
66
|
-
useCache: stringToBoolean(useCache, false),
|
|
67
|
-
method: c.req.method,
|
|
68
|
-
url: c.req.url,
|
|
69
|
-
path: c.req.path,
|
|
70
|
-
});
|
|
71
|
-
await next();
|
|
72
|
-
const duration = Date.now() - start;
|
|
73
|
-
Cfg.server.logger(c, {
|
|
74
|
-
mode: "outgoing",
|
|
75
|
-
duration,
|
|
76
|
-
start,
|
|
77
|
-
action,
|
|
78
|
-
collection,
|
|
79
|
-
cleanDeep,
|
|
80
|
-
useCache: stringToBoolean(useCache, false),
|
|
81
|
-
method: c.req.method,
|
|
82
|
-
url: c.req.url,
|
|
83
|
-
status: c.res.status,
|
|
84
|
-
path: c.req.path,
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
if (typeof Cfg?.server?.logger == "boolean" && Cfg?.server?.logger) {
|
|
89
|
-
app.use(async (c, next) => {
|
|
90
|
-
let ip =
|
|
91
|
-
c.req.raw.headers?.get("CF-Connecting-IP") ||
|
|
92
|
-
c.req.raw.headers?.get("x-forwarded-for") ||
|
|
93
|
-
c.req.raw.headers?.get("x-real-ip");
|
|
94
|
-
const origin =
|
|
95
|
-
c.req?.header("Origin") || c.req.raw?.headers?.get("Origin") || "";
|
|
96
|
-
const info = getConnInfo(c);
|
|
97
|
-
if (c.req.method == "OPTIONS") return await next();
|
|
98
|
-
const start = Date.now();
|
|
99
|
-
const { action, collection, cleanDeep, useCache, name } =
|
|
100
|
-
c.req.query() as Q;
|
|
101
|
-
// Log the incoming request
|
|
102
|
-
console.log(
|
|
103
|
-
`<-- ${ip || info.remote.address} ${origin} | ${c.req.method.gray} ${
|
|
104
|
-
c.req.path?.gray
|
|
105
|
-
} -C ${colors.blue(`${collection || ""}`)} -A ${
|
|
106
|
-
action?.gray || ""
|
|
107
|
-
} -Sn ${name?.gray || ""} -t ${
|
|
108
|
-
moment(start).format("YYYY-DD-MM:HH:mm:ss").gray
|
|
109
|
-
} \n`
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
await next();
|
|
113
|
-
// Calculate the duration of the request processing
|
|
114
|
-
const duration = Date.now() - start;
|
|
115
|
-
console.log(
|
|
116
|
-
`--> ${ip || info.remote.address} ${origin} | ${c.req.method.gray} ${
|
|
117
|
-
c.req.path?.gray
|
|
118
|
-
} -C ${colors.blue(`${collection || ""}`)} -A ${
|
|
119
|
-
action?.gray || ""
|
|
120
|
-
} -Sn ${name?.gray || ""} -s ${c.res.status} -d ${colors.green(
|
|
121
|
-
`(${duration}ms)`
|
|
122
|
-
)} -t ${moment().format("YYYY-DD-MM:HH:mm:ss").gray} \n`
|
|
123
|
-
);
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
55
|
app.use(
|
|
128
56
|
ipRestriction(getConnInfo, {
|
|
129
57
|
allowList: Cfg?.server?.whiteListIps || [],
|
|
@@ -160,12 +88,10 @@ function HonoInstance(): typeof app {
|
|
|
160
88
|
app.use(async (c, next) => {
|
|
161
89
|
return asyncLocalStorage.run(new Map(), async () => {
|
|
162
90
|
let cookie = getCookie(c);
|
|
163
|
-
let secretKeyStudio = cookie["_STUDIO_SECRET_KEY_"] || null;
|
|
164
91
|
let session = sessionStorage();
|
|
165
92
|
var token = jwt.getToken("Bearer", c.req.header()["authorization"]) || "";
|
|
166
93
|
var { decode, valid, error } = jwt.verify(token);
|
|
167
94
|
let sessionData = {};
|
|
168
|
-
|
|
169
95
|
if (valid && decode) {
|
|
170
96
|
await localSession
|
|
171
97
|
.get(decode?.sessionId)
|
package/lib/socket/instance.ts
CHANGED
package/package.json
CHANGED
package/types/index.ts
CHANGED
|
@@ -364,12 +364,19 @@ export type Config = {
|
|
|
364
364
|
server: {
|
|
365
365
|
logger?: Boolean | loggerFunction;
|
|
366
366
|
whiteListIps?: Array<string>;
|
|
367
|
-
blackListIps?:
|
|
367
|
+
blackListIps?: string[];
|
|
368
368
|
cors?: {
|
|
369
|
-
origin:
|
|
369
|
+
origin:
|
|
370
|
+
| string[]
|
|
371
|
+
| ((ctx: { origin: string; c: Context }) => string[])
|
|
372
|
+
| string;
|
|
373
|
+
/**
|
|
374
|
+
* default true
|
|
375
|
+
@default true
|
|
376
|
+
*/
|
|
370
377
|
credentials?: boolean;
|
|
371
|
-
allowMethods?:
|
|
372
|
-
allowHeaders?:
|
|
378
|
+
allowMethods?: string[];
|
|
379
|
+
allowHeaders?: string[];
|
|
373
380
|
};
|
|
374
381
|
socket?: {
|
|
375
382
|
/**
|