@dnax/core 0.28.0 → 0.29.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/index.ts CHANGED
@@ -12,10 +12,11 @@ import findPort from "find-open-port";
12
12
  import { Server } from "socket.io";
13
13
  import { webSocketServer } from "../lib/socket/instance";
14
14
  import { HonoInstance } from "./hono";
15
+ import { utils } from "..";
15
16
  type configRunApp = {
16
17
  register?: Array<Function>;
17
18
  beforeStart?: Array<Function>;
18
- afterStart?: Array<Function>;
19
+ afterStart?: Array<(ctx: { config: typeof Cfg }) => void>;
19
20
  onError?: Array<Function>;
20
21
  destroy?: Array<Function>;
21
22
  dbSync?: Array<Function>;
@@ -115,7 +116,9 @@ async function runApp(config?: configRunApp, clb?: Function) {
115
116
  //AfterStart
116
117
  if (config?.afterStart) {
117
118
  for (const fn of config?.afterStart) {
118
- await fn();
119
+ await fn({
120
+ config: utils.copy(Cfg),
121
+ });
119
122
  }
120
123
  }
121
124
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.28.0",
3
+ "version": "0.29.1",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "bin": {
package/utils/index.ts CHANGED
@@ -28,8 +28,7 @@ function copy(data: object): object | any {
28
28
 
29
29
  const jwt = {
30
30
  verify: (token: string): { decode: any; valid: boolean; error: any } => {
31
- const JWT_SECRET =
32
- Cfg.server.jwt?.secret || String(process?.env?.JWT_SECRET);
31
+ const JWT_SECRET = String(Cfg.server?.jwt?.secret);
33
32
  let decode = null;
34
33
  let valid = true;
35
34
  let error = null;
@@ -59,21 +58,23 @@ const jwt = {
59
58
  expiresIn: "7d",
60
59
  }
61
60
  ) => {
62
- // console.log("payload", payload, options);
63
- const JWT_SECRET =
64
- Cfg.server.jwt?.secret || String(process?.env?.JWT_SECRET);
65
- return jwto.sign({ session: payload }, JWT_SECRET, {
66
- ...options,
67
- });
61
+ try {
62
+ // console.log("payload", payload, options);
63
+ const JWT_SECRET = String(Cfg.server.jwt?.secret);
64
+ return jwto.sign({ session: payload }, JWT_SECRET, {
65
+ ...options,
66
+ });
67
+ } catch (err) {
68
+ console.error(err?.message);
69
+ }
68
70
  },
69
71
  auth: (
70
72
  payload: any = {},
71
73
  options: { expiresIn: string } = {
72
- expiresIn: process.env?.JWT_EXPIRES_IN || "7d",
74
+ expiresIn: "7d",
73
75
  }
74
76
  ) => {
75
- const JWT_SECRET =
76
- Cfg.server.jwt?.secret || String(process?.env?.JWT_SECRET);
77
+ const JWT_SECRET = String(Cfg.server.jwt?.secret);
77
78
 
78
79
  return jwto.sign(
79
80
  {