@dnax/core 0.13.8 → 0.14.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 +1 -1
- package/app/index.ts +3 -0
- package/driver/mongo/rest.ts +7 -0
- package/lib/index.ts +1 -4
- package/lib/service.ts +1 -1
- package/lib/socket.ts +7 -9
- package/package.json +7 -5
- package/types/index.ts +1 -1
package/app/hono.ts
CHANGED
|
@@ -364,7 +364,7 @@ function HonoInstance(): typeof app {
|
|
|
364
364
|
// Exec service
|
|
365
365
|
if (action == "execService") {
|
|
366
366
|
if (!service) return fn.error("Service not found", 404);
|
|
367
|
-
let fx = service
|
|
367
|
+
let fx = service?.exec || service?.fx;
|
|
368
368
|
if (fx) {
|
|
369
369
|
response = await fx({
|
|
370
370
|
io: Cfg.io,
|
package/app/index.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { init } from "../lib";
|
|
|
4
4
|
import { hookDatabase } from "../lib/database";
|
|
5
5
|
import killPort from "kill-port";
|
|
6
6
|
import boxen from "boxen";
|
|
7
|
+
import { loadSocket } from "../lib/socket";
|
|
8
|
+
import pidusage from "pidusage";
|
|
7
9
|
import "@colors/colors";
|
|
8
10
|
import pkg from "../package.json";
|
|
9
11
|
import findPort from "find-open-port";
|
|
@@ -39,6 +41,7 @@ async function runApp(config?: configRunApp, clb?: Function) {
|
|
|
39
41
|
// Load all ressouce
|
|
40
42
|
await init();
|
|
41
43
|
const HonoApp = HonoInstance();
|
|
44
|
+
await loadSocket(HonoApp);
|
|
42
45
|
//BeforeStart
|
|
43
46
|
if (config?.beforeStart) {
|
|
44
47
|
for (const fn of config?.beforeStart) {
|
package/driver/mongo/rest.ts
CHANGED
|
@@ -71,6 +71,11 @@ class useRest {
|
|
|
71
71
|
#tenant_id: string;
|
|
72
72
|
#session: ClientSession | null | undefined;
|
|
73
73
|
#useCustomApi: boolean = true;
|
|
74
|
+
/**
|
|
75
|
+
Direct Api Mongo , use it with caution
|
|
76
|
+
*/
|
|
77
|
+
db: Tenant["database"]["db"];
|
|
78
|
+
|
|
74
79
|
constructor(options: options) {
|
|
75
80
|
this.#c = options.c;
|
|
76
81
|
this.#useCustomApi = options.useCustomApi ?? true;
|
|
@@ -78,6 +83,8 @@ class useRest {
|
|
|
78
83
|
this.#session = null;
|
|
79
84
|
this.#tenant = getTenant(this.#tenant_id);
|
|
80
85
|
this.#useHook = options?.useHook ?? true;
|
|
86
|
+
this.db = this.#tenant.database.db;
|
|
87
|
+
|
|
81
88
|
/* if (options?.useHook == undefined || options?.useHook == null) {
|
|
82
89
|
this.#useHook = true;
|
|
83
90
|
} else {
|
package/lib/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { loadEndpoints } from "./endpoint";
|
|
|
4
4
|
import { loadServices } from "./service";
|
|
5
5
|
import { initCron } from "./cron";
|
|
6
6
|
import { loadPermissions } from "./permissions";
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
import { loadAutoRoutes } from "./routes";
|
|
9
9
|
// load all ressource
|
|
10
10
|
async function init(cf = { app: null }) {
|
|
@@ -22,9 +22,6 @@ async function init(cf = { app: null }) {
|
|
|
22
22
|
// load Service
|
|
23
23
|
loadServices();
|
|
24
24
|
|
|
25
|
-
// load Socket
|
|
26
|
-
await loadSocket();
|
|
27
|
-
|
|
28
25
|
// load all loadEndpoints
|
|
29
26
|
await loadEndpoints();
|
|
30
27
|
|
package/lib/service.ts
CHANGED
|
@@ -36,7 +36,7 @@ async function loadServices() {
|
|
|
36
36
|
|
|
37
37
|
function getService(name: string, tenant_id: string): Service | undefined {
|
|
38
38
|
return Cfg.services?.find(
|
|
39
|
-
(s) => s?.tenant_id == tenant_id && s?.name == name && s?.fx
|
|
39
|
+
(s) => s?.tenant_id == tenant_id && s?.name == name && (s?.fx || s?.exec)
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
42
|
|
package/lib/socket.ts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { Cfg } from "../config";
|
|
2
2
|
import { Server } from "socket.io";
|
|
3
|
+
import type { Hono } from "hono";
|
|
4
|
+
import { createServer } from "http";
|
|
3
5
|
import consola from "consola";
|
|
4
6
|
import { Glob } from "bun";
|
|
5
7
|
import path from "path";
|
|
6
8
|
import { useRest } from "../driver/mongo";
|
|
7
|
-
async function loadSocket() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
credentials: true,
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
/* io.on("connection", (socket) => {
|
|
9
|
+
async function loadSocket(app: InstanceType<typeof Hono>) {
|
|
10
|
+
let httpServer = createServer(app.fetch);
|
|
11
|
+
var io = new Server(httpServer);
|
|
12
|
+
io.on("connection", (socket) => {
|
|
15
13
|
console.log("ok");
|
|
16
|
-
});
|
|
14
|
+
});
|
|
17
15
|
if (Cfg.tenants) {
|
|
18
16
|
for await (let t of Cfg.tenants) {
|
|
19
17
|
let tenantPath = `${t.dir}/sockets/**/**.ws.{ts,js}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dnax/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"module": "index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"@types/fs-extra": "^11.0.4",
|
|
12
12
|
"@types/mime-types": "^2.1.4",
|
|
13
13
|
"@types/nodemailer": "^6.4.15",
|
|
14
|
+
"@types/pidusage": "^2.0.5",
|
|
14
15
|
"@types/uuid": "^10.0.0"
|
|
15
16
|
},
|
|
16
17
|
"peerDependencies": {
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
"find-open-port": "^2.0.3",
|
|
38
39
|
"fs-extra": "^11.2.0",
|
|
39
40
|
"generate-unique-id": "^2.0.3",
|
|
40
|
-
"groq-sdk": "^0.
|
|
41
|
+
"groq-sdk": "^0.8.0",
|
|
41
42
|
"hono": "^4.6.3",
|
|
42
43
|
"joi": "^17.13.3",
|
|
43
44
|
"json-joy": "^16.8.0",
|
|
@@ -45,14 +46,15 @@
|
|
|
45
46
|
"mime-types": "^2.1.35",
|
|
46
47
|
"mingo": "^6.4.15",
|
|
47
48
|
"moment": "^2.30.1",
|
|
48
|
-
"mongodb": "^6.
|
|
49
|
+
"mongodb": "^6.10.0",
|
|
49
50
|
"nodemailer": "^6.9.14",
|
|
50
51
|
"ollama": "^0.5.9",
|
|
51
|
-
"openai": "^4.
|
|
52
|
+
"openai": "^4.72.0",
|
|
53
|
+
"pidusage": "^3.0.2",
|
|
52
54
|
"radash": "^12.1.0",
|
|
53
55
|
"sharp": "^0.33.5",
|
|
54
56
|
"signaldb": "^0.18.0",
|
|
55
|
-
"socket.io": "^4.
|
|
57
|
+
"socket.io": "^4.8.1",
|
|
56
58
|
"ufo": "^1.5.3",
|
|
57
59
|
"urlencode": "^2.0.0",
|
|
58
60
|
"uuid": "^10.0.0"
|