@dnax/core 0.5.0 → 0.5.1
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 +22 -3
- package/package.json +2 -2
- package/types/index.ts +6 -0
package/app/hono.ts
CHANGED
|
@@ -20,16 +20,35 @@ 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(async (c, next) => {
|
|
32
|
+
Cfg?.server?.logger(c);
|
|
33
|
+
return await next();
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (typeof Cfg?.server?.logger == "boolean") {
|
|
37
|
+
app.use(logger());
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
app.use(
|
|
41
|
+
ipRestriction(getConnInfo, {
|
|
42
|
+
allowList: Cfg?.server?.whiteListIps || [],
|
|
43
|
+
denyList: Cfg?.server?.blackListIps || [],
|
|
44
|
+
// blackList: Cfg.server?.ipBlackList || [],
|
|
45
|
+
})
|
|
46
|
+
);
|
|
27
47
|
app.use(secureHeaders());
|
|
28
|
-
|
|
29
48
|
app.use(
|
|
30
49
|
cors({
|
|
31
50
|
origin: Cfg.server?.cors?.origin || [],
|
|
32
|
-
credentials: true,
|
|
51
|
+
credentials: Cfg.server?.cors?.credentials || true,
|
|
33
52
|
})
|
|
34
53
|
);
|
|
35
54
|
//eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoibm9tIiwiaWF0IjoxNzE3Nzc0MDQzLCJleHAiOjE3MTc3NzQxMDN9.Ud4-0y8pa4SMIcSn8PU1A-sjC-hT4ZVe_u3AdChyIJU
|
|
@@ -382,7 +401,7 @@ function HonoInstance(): typeof app {
|
|
|
382
401
|
|
|
383
402
|
return c.json(response);
|
|
384
403
|
} catch (err: any) {
|
|
385
|
-
|
|
404
|
+
if (Cfg?.debug) console.log(err?.message | err);
|
|
386
405
|
if (err?.code && (err?.code < 200 || err?.code > 599)) {
|
|
387
406
|
err.code = 409;
|
|
388
407
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dnax/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
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 = (c: Context) => 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
|
/**
|