@dnax/core 0.5.0 → 0.5.2
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 +19 -3
- package/package.json +2 -2
- package/types/index.ts +6 -0
package/app/hono.ts
CHANGED
|
@@ -20,16 +20,32 @@ import { pick } from "radash";
|
|
|
20
20
|
import { secureHeaders } from "hono/secure-headers";
|
|
21
21
|
import { getTenant } from "../lib/tenant";
|
|
22
22
|
import { checkPermission, getPermission } from "../lib/permissions";
|
|
23
|
+
import { ipRestriction } from "hono/ip-restriction";
|
|
24
|
+
import { logger } from "hono/logger";
|
|
23
25
|
const app = new Hono();
|
|
24
26
|
|
|
25
27
|
const API_PATH = "/api";
|
|
26
28
|
function HonoInstance(): typeof app {
|
|
29
|
+
if (Cfg?.server?.logger) {
|
|
30
|
+
if (typeof Cfg?.server?.logger == "function") {
|
|
31
|
+
app.use(logger(Cfg?.server?.logger));
|
|
32
|
+
}
|
|
33
|
+
if (typeof Cfg?.server?.logger == "boolean") {
|
|
34
|
+
app.use(logger());
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
app.use(
|
|
38
|
+
ipRestriction(getConnInfo, {
|
|
39
|
+
allowList: Cfg?.server?.whiteListIps || [],
|
|
40
|
+
denyList: Cfg?.server?.blackListIps || [],
|
|
41
|
+
// blackList: Cfg.server?.ipBlackList || [],
|
|
42
|
+
})
|
|
43
|
+
);
|
|
27
44
|
app.use(secureHeaders());
|
|
28
|
-
|
|
29
45
|
app.use(
|
|
30
46
|
cors({
|
|
31
47
|
origin: Cfg.server?.cors?.origin || [],
|
|
32
|
-
credentials: true,
|
|
48
|
+
credentials: Cfg.server?.cors?.credentials || true,
|
|
33
49
|
})
|
|
34
50
|
);
|
|
35
51
|
//eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoibm9tIiwiaWF0IjoxNzE3Nzc0MDQzLCJleHAiOjE3MTc3NzQxMDN9.Ud4-0y8pa4SMIcSn8PU1A-sjC-hT4ZVe_u3AdChyIJU
|
|
@@ -382,7 +398,7 @@ function HonoInstance(): typeof app {
|
|
|
382
398
|
|
|
383
399
|
return c.json(response);
|
|
384
400
|
} catch (err: any) {
|
|
385
|
-
|
|
401
|
+
if (Cfg?.debug) console.log(err?.message | err);
|
|
386
402
|
if (err?.code && (err?.code < 200 || err?.code > 599)) {
|
|
387
403
|
err.code = 409;
|
|
388
404
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dnax/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"module": "index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"find-open-port": "^2.0.3",
|
|
30
30
|
"fs-extra": "^11.2.0",
|
|
31
31
|
"generate-unique-id": "^2.0.3",
|
|
32
|
-
"hono": "^4.5.
|
|
32
|
+
"hono": "^4.5.9",
|
|
33
33
|
"joi": "^17.13.3",
|
|
34
34
|
"json-joy": "^16.8.0",
|
|
35
35
|
"jsonwebtoken": "^9.0.2",
|
package/types/index.ts
CHANGED
|
@@ -294,6 +294,8 @@ export type Collection = {
|
|
|
294
294
|
}>;
|
|
295
295
|
};
|
|
296
296
|
|
|
297
|
+
export type loggerFunction = (message: string, rest: any) => void;
|
|
298
|
+
|
|
297
299
|
export type Config = {
|
|
298
300
|
email?: {
|
|
299
301
|
provider: "smtp";
|
|
@@ -335,8 +337,12 @@ export type Config = {
|
|
|
335
337
|
};
|
|
336
338
|
|
|
337
339
|
server: {
|
|
340
|
+
logger?: Boolean | loggerFunction;
|
|
341
|
+
whiteListIps?: Array<string>;
|
|
342
|
+
blackListIps?: Array<string>;
|
|
338
343
|
cors?: {
|
|
339
344
|
origin: string[];
|
|
345
|
+
credentials?: boolean;
|
|
340
346
|
};
|
|
341
347
|
socket?: {
|
|
342
348
|
/**
|