@dnax/core 0.5.4 → 0.5.6

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 CHANGED
@@ -2,7 +2,7 @@ import type { Q, Tenant, sessionCtx } from "../types/";
2
2
 
3
3
  import { Hono } from "hono";
4
4
  import { getCookie, setCookie } from "hono/cookie";
5
-
5
+ import colors from "@colors/colors/safe";
6
6
  import { serveStatic, getConnInfo } from "hono/bun";
7
7
  import { consola } from "consola";
8
8
  import { cors } from "hono/cors";
@@ -22,6 +22,7 @@ import { getTenant } from "../lib/tenant";
22
22
  import { checkPermission, getPermission } from "../lib/permissions";
23
23
  import { ipRestriction } from "hono/ip-restriction";
24
24
  import { logger } from "hono/logger";
25
+ import { v4 } from "uuid";
25
26
  const app = new Hono();
26
27
 
27
28
  const API_PATH = "/api";
@@ -40,6 +41,7 @@ function HonoInstance(): typeof app {
40
41
  useCache: useCache,
41
42
  method: c.req.method,
42
43
  url: c.req.url,
44
+ path: c.req.path,
43
45
  });
44
46
  await next();
45
47
  const duration = Date.now() - start;
@@ -54,27 +56,36 @@ function HonoInstance(): typeof app {
54
56
  method: c.req.method,
55
57
  url: c.req.url,
56
58
  status: c.res.status,
59
+ path: c.req.path,
57
60
  });
58
61
  });
59
62
  }
60
63
  if (typeof Cfg?.server?.logger == "boolean" && Cfg?.server?.logger) {
61
64
  app.use(async (c, next) => {
65
+ const info = getConnInfo(c);
66
+ if (c.req.method == "OPTIONS") return await next();
62
67
  const start = Date.now();
63
68
  const { action, collection, cleanDeep, useCache } = c.req.query() as Q;
64
69
  // Log the incoming request
65
70
  console.log(
66
- `<-- ${c.req.method} /${c.req.url} - C ${collection || ""} - A ${
67
- action || ""
68
- }\n`
71
+ `<-- ${info.remote.address} | ${c.req.method.gray} ${
72
+ c.req.path?.gray
73
+ } -C ${colors.blue(`${collection || ""}`)} -A ${
74
+ action?.gray || ""
75
+ } -T ${moment(start).format("YYYY-DD-MM:HH:mm:ss").gray} \n`
69
76
  );
70
77
 
71
78
  await next();
72
79
  // Calculate the duration of the request processing
73
80
  const duration = Date.now() - start;
74
81
  console.log(
75
- `--> ${c.req.method} /${c.req.url} - C ${collection || ""} - A ${
76
- action || ""
77
- } - ${c.res.status} - (${duration + "".green}ms)\n`
82
+ `--> ${info.remote.address} | ${c.req.method.gray} ${
83
+ c.req.path?.gray
84
+ } -C ${colors.blue(`${collection || ""}`)} -A ${
85
+ action?.gray || ""
86
+ } -S ${c.res.status} -D ${colors.green(`(${duration}ms)`)} -T ${
87
+ moment().format("YYYY-DD-MM:HH:mm:ss").gray
88
+ } \n`
78
89
  );
79
90
  });
80
91
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "bin": {
package/types/index.ts CHANGED
@@ -307,6 +307,7 @@ export type loggerFunction = (
307
307
  url?: string;
308
308
  status?: number;
309
309
  duration?: number;
310
+ path?: string;
310
311
  }
311
312
  ) => void;
312
313