@dnax/core 0.1.11 → 0.1.13

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
@@ -6,7 +6,14 @@ import "@colors/colors";
6
6
  import pkg from "../package.json";
7
7
  import findPort from "find-open-port";
8
8
  import { HonoInstance } from "./hono";
9
- async function runApp(config?: any, clb?: Function) {
9
+ type configRunApp = {
10
+ register?: Array<Function>,
11
+ beforeStart?: Array<Function>,
12
+ afterStart?: Array<Function>,
13
+ onError?: Array<Function>,
14
+ destroy?: Array<Function>,
15
+ }
16
+ async function runApp(config?: configRunApp, clb?: Function) {
10
17
  console.log("\n");
11
18
 
12
19
  await loadCfg();
@@ -15,18 +22,30 @@ async function runApp(config?: any, clb?: Function) {
15
22
  // Load all ressouce
16
23
  await init();
17
24
 
25
+ // Register all plugins
26
+
18
27
  // Load Hono App and route api
19
28
  const HonoApp = HonoInstance();
20
29
  const PORT = Cfg.server?.port || process.env?.PORT || 4000;
21
30
 
22
- await findPort.isAvailable(PORT).then((available: boolean) => {
31
+ await findPort.isAvailable(PORT).then(async (available: boolean) => {
23
32
  // Start App server
24
33
 
25
34
  if (available) {
35
+
36
+
37
+ //BeforeStart
38
+ if (config?.beforeStart) {
39
+ for (const fn of config?.beforeStart) {
40
+ await fn();
41
+ }
42
+ }
43
+
26
44
  Bun.serve({
27
45
  port: PORT,
28
46
  fetch: HonoApp.fetch,
29
47
  maxRequestBodySize: 1024 * 1024 * 900,
48
+
30
49
  });
31
50
 
32
51
  console.log();
@@ -35,9 +54,8 @@ async function runApp(config?: any, clb?: Function) {
35
54
  info += `\n`;
36
55
  info += `\n`;
37
56
  info +=
38
- `Env: ${
39
- process.env.NODE_ENV === "production" ? "production" : "development"
40
- }`.italic.blue.green + "\n";
57
+ `Env: ${process.env.NODE_ENV === "production" ? "production" : "development"
58
+ }`.italic.blue.green + "\n";
41
59
  info += `Server: http://localhost:${PORT}\n`.italic.blue;
42
60
  info += `\n`;
43
61
  info += "TENANTS DETAILS :".gray.italic.underline;
@@ -61,6 +79,14 @@ async function runApp(config?: any, clb?: Function) {
61
79
  borderColor: "gray",
62
80
  })
63
81
  );
82
+
83
+ //AfterStart
84
+ if (config?.afterStart) {
85
+ for (const fn of config?.afterStart) {
86
+ await fn();
87
+ }
88
+ }
89
+
64
90
  } else {
65
91
  console.error(`⚠️ Port ${PORT} is not available`);
66
92
  console.log("");
@@ -827,6 +827,7 @@ class useRest {
827
827
  {
828
828
  upsert: true,
829
829
  returnDocument: "after",
830
+
830
831
  session: this.#session ? this.#session : undefined,
831
832
  }
832
833
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "devDependencies": {