libmodulor 0.12.0 → 0.13.0
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/CHANGELOG.md +10 -0
- package/README.md +1 -1
- package/dist/esm/apps/Helper/src/lib/project.js +4 -4
- package/dist/esm/index.node-hono.d.ts +2 -0
- package/dist/esm/index.node-hono.js +2 -0
- package/dist/esm/target/nextjs-server/NextJSAPIRouteHandler.js +1 -1
- package/dist/esm/target/node-hono-server/NodeHonoServerManager.d.ts +35 -0
- package/dist/esm/target/node-hono-server/NodeHonoServerManager.js +169 -0
- package/package.json +13 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## v0.13.0 (2025-04-25)
|
|
4
|
+
|
|
5
|
+
**Added**
|
|
6
|
+
|
|
7
|
+
- Introduce `target/node-hono-server` allowing you to expose a server using [Hono](https://hono.dev) in addition to the existing implementations based on [express](https://expressjs.com) and [next.js](https://nextjs.org)
|
|
8
|
+
|
|
9
|
+
**Misc**
|
|
10
|
+
|
|
11
|
+
- Upgrade `examples/supertrader` to rn `react-native@0.79.x` and `expo@53.x`
|
|
12
|
+
|
|
3
13
|
## v0.12.0 (2025-04-13)
|
|
4
14
|
|
|
5
15
|
**BREAKING**
|
package/README.md
CHANGED
|
@@ -36,23 +36,23 @@ export const PACKAGE_JSON = (name) => `{
|
|
|
36
36
|
"test": "tsc && vitest run --passWithNoTests"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"inversify": "^7.5.
|
|
39
|
+
"inversify": "^7.5.1",
|
|
40
40
|
"libmodulor": "latest",
|
|
41
41
|
"reflect-metadata": "^0.2.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@biomejs/biome": "^1.9.4",
|
|
45
|
-
"@types/node": "^22.14.
|
|
45
|
+
"@types/node": "^22.14.1",
|
|
46
46
|
"@vitest/coverage-v8": "^3.1.1",
|
|
47
47
|
"buffer": "^6.0.3",
|
|
48
48
|
"cookie-parser": "^1.4.7",
|
|
49
49
|
"express": "^5.1.0",
|
|
50
50
|
"express-fileupload": "^1.5.1",
|
|
51
|
-
"fast-check": "^4.1.
|
|
51
|
+
"fast-check": "^4.1.1",
|
|
52
52
|
"helmet": "^8.1.0",
|
|
53
53
|
"jose": "^6.0.10",
|
|
54
54
|
"typescript": "^5.8.3",
|
|
55
|
-
"vite": "^6.2
|
|
55
|
+
"vite": "^6.3.2",
|
|
56
56
|
"vitest": "^3.1.1"
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -48,7 +48,7 @@ let NextJSAPIRouteHandler = class NextJSAPIRouteHandler {
|
|
|
48
48
|
}
|
|
49
49
|
toReq(req) {
|
|
50
50
|
return {
|
|
51
|
-
bodyFromFormData: async () => fromFormData(await req.formData()),
|
|
51
|
+
bodyFromFormData: async () => fromFormData((await req.formData())),
|
|
52
52
|
bodyFromJSON: () => req.json(),
|
|
53
53
|
bodyFromQueryParams: async () => fromQueryParams(req.nextUrl),
|
|
54
54
|
bodyRaw: req.body,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import type { AppManifest } from '../../app/index.js';
|
|
3
|
+
import type { DirPath } from '../../dt/index.js';
|
|
4
|
+
import type { Configurable, EnvironmentManager, Logger, SettingsManager } from '../../std/index.js';
|
|
5
|
+
import type { UCDef, UCHTTPContract, UCInput, UCManager, UCOPIBase } from '../../uc/index.js';
|
|
6
|
+
import { EntrypointsBuilder } from '../lib/server/EntrypointsBuilder.js';
|
|
7
|
+
import type { ServerManager, ServerManagerSettings } from '../lib/server/ServerManager.js';
|
|
8
|
+
import { ServerRequestHandler } from '../lib/server/ServerRequestHandler.js';
|
|
9
|
+
import { ServerSSLCertLoader } from '../lib/server/ServerSSLCertLoader.js';
|
|
10
|
+
type S = Pick<ServerManagerSettings, 'server_binding_host' | 'server_binding_port'>;
|
|
11
|
+
export declare class NodeHonoServerManager implements Configurable<S>, ServerManager {
|
|
12
|
+
private entrypointsBuilder;
|
|
13
|
+
protected environmentManager: EnvironmentManager;
|
|
14
|
+
private logger;
|
|
15
|
+
private serverRequestHandler;
|
|
16
|
+
private serverSSLCertLoader;
|
|
17
|
+
private settingsManager;
|
|
18
|
+
private ucManager;
|
|
19
|
+
protected runtime: Hono;
|
|
20
|
+
private server;
|
|
21
|
+
constructor(entrypointsBuilder: EntrypointsBuilder, environmentManager: EnvironmentManager, logger: Logger, serverRequestHandler: ServerRequestHandler, serverSSLCertLoader: ServerSSLCertLoader, settingsManager: SettingsManager<S>, ucManager: UCManager);
|
|
22
|
+
s(): S;
|
|
23
|
+
getRuntime(): Hono;
|
|
24
|
+
overrideUCManager(ucManager: UCManager): void;
|
|
25
|
+
init(): Promise<void>;
|
|
26
|
+
mount<I extends UCInput | undefined = undefined, OPI0 extends UCOPIBase | undefined = undefined, OPI1 extends UCOPIBase | undefined = undefined>(appManifest: AppManifest, ucd: UCDef<I, OPI0, OPI1>, contract: UCHTTPContract): Promise<void>;
|
|
27
|
+
mountStaticDir(dirPath: DirPath): Promise<void>;
|
|
28
|
+
start(): Promise<void>;
|
|
29
|
+
stop(): Promise<void>;
|
|
30
|
+
warmUp(): Promise<void>;
|
|
31
|
+
private createServer;
|
|
32
|
+
private toReq;
|
|
33
|
+
private toRes;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import http from 'node:http';
|
|
14
|
+
import https from 'node:https';
|
|
15
|
+
import { createAdaptorServer, } from '@hono/node-server';
|
|
16
|
+
import { serveStatic } from '@hono/node-server/serve-static';
|
|
17
|
+
import { Hono } from 'hono';
|
|
18
|
+
import { deleteCookie, getCookie, setCookie } from 'hono/cookie';
|
|
19
|
+
import { logger } from 'hono/logger';
|
|
20
|
+
import { secureHeaders } from 'hono/secure-headers';
|
|
21
|
+
import { inject, injectable } from 'inversify';
|
|
22
|
+
import { fromFormData } from '../../utils/index.js';
|
|
23
|
+
import { stop } from '../lib/server-node/stop.js';
|
|
24
|
+
import { EntrypointsBuilder } from '../lib/server/EntrypointsBuilder.js';
|
|
25
|
+
import { ServerRequestHandler, } from '../lib/server/ServerRequestHandler.js';
|
|
26
|
+
import { ServerSSLCertLoader } from '../lib/server/ServerSSLCertLoader.js';
|
|
27
|
+
let NodeHonoServerManager = class NodeHonoServerManager {
|
|
28
|
+
entrypointsBuilder;
|
|
29
|
+
environmentManager;
|
|
30
|
+
logger;
|
|
31
|
+
serverRequestHandler;
|
|
32
|
+
serverSSLCertLoader;
|
|
33
|
+
settingsManager;
|
|
34
|
+
ucManager;
|
|
35
|
+
runtime;
|
|
36
|
+
server;
|
|
37
|
+
constructor(entrypointsBuilder, environmentManager, logger, serverRequestHandler, serverSSLCertLoader, settingsManager, ucManager) {
|
|
38
|
+
this.entrypointsBuilder = entrypointsBuilder;
|
|
39
|
+
this.environmentManager = environmentManager;
|
|
40
|
+
this.logger = logger;
|
|
41
|
+
this.serverRequestHandler = serverRequestHandler;
|
|
42
|
+
this.serverSSLCertLoader = serverSSLCertLoader;
|
|
43
|
+
this.settingsManager = settingsManager;
|
|
44
|
+
this.ucManager = ucManager;
|
|
45
|
+
}
|
|
46
|
+
s() {
|
|
47
|
+
return {
|
|
48
|
+
server_binding_host: this.settingsManager.get()('server_binding_host'),
|
|
49
|
+
server_binding_port: this.settingsManager.get()('server_binding_port'),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
getRuntime() {
|
|
53
|
+
if (this.environmentManager.isProd()) {
|
|
54
|
+
throw new Error('Do not use getRuntime() in production !');
|
|
55
|
+
}
|
|
56
|
+
return this.runtime;
|
|
57
|
+
}
|
|
58
|
+
overrideUCManager(ucManager) {
|
|
59
|
+
this.ucManager = ucManager;
|
|
60
|
+
}
|
|
61
|
+
async init() {
|
|
62
|
+
this.runtime = new Hono();
|
|
63
|
+
this.runtime.use(secureHeaders());
|
|
64
|
+
this.runtime.use(logger());
|
|
65
|
+
this.runtime.notFound((c) => {
|
|
66
|
+
return c.json({}, 404);
|
|
67
|
+
});
|
|
68
|
+
await this.createServer();
|
|
69
|
+
}
|
|
70
|
+
async mount(appManifest, ucd, contract) {
|
|
71
|
+
const { envelope, method, path, pathAliases } = contract;
|
|
72
|
+
const httpMethod = method.toLowerCase();
|
|
73
|
+
if (httpMethod === 'connect' ||
|
|
74
|
+
httpMethod === 'head' ||
|
|
75
|
+
httpMethod === 'trace') {
|
|
76
|
+
throw new Error(`Unsupported HTTP method : ${httpMethod}`);
|
|
77
|
+
}
|
|
78
|
+
const handler = async (c) => {
|
|
79
|
+
const { body, status } = await this.serverRequestHandler.exec({
|
|
80
|
+
appManifest,
|
|
81
|
+
envelope,
|
|
82
|
+
req: this.toReq(c),
|
|
83
|
+
res: this.toRes(c),
|
|
84
|
+
ucd,
|
|
85
|
+
ucManager: this.ucManager,
|
|
86
|
+
});
|
|
87
|
+
if (!body) {
|
|
88
|
+
return c.newResponse(null, status);
|
|
89
|
+
}
|
|
90
|
+
return c.json(body, status);
|
|
91
|
+
};
|
|
92
|
+
this.runtime[httpMethod](path, handler);
|
|
93
|
+
for (const pathAlias of pathAliases) {
|
|
94
|
+
this.runtime[httpMethod](pathAlias, handler);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async mountStaticDir(dirPath) {
|
|
98
|
+
this.runtime.use(serveStatic({ root: dirPath }));
|
|
99
|
+
}
|
|
100
|
+
async start() {
|
|
101
|
+
const host = this.s().server_binding_host;
|
|
102
|
+
const port = this.s().server_binding_port;
|
|
103
|
+
this.server.listen(port, host, () => {
|
|
104
|
+
this.logger.info(`Listening on ${this.entrypointsBuilder.exec().http}`);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
async stop() {
|
|
108
|
+
await stop(this.server);
|
|
109
|
+
}
|
|
110
|
+
async warmUp() {
|
|
111
|
+
// Nothing to do
|
|
112
|
+
}
|
|
113
|
+
async createServer() {
|
|
114
|
+
const host = this.s().server_binding_host;
|
|
115
|
+
const port = this.s().server_binding_port;
|
|
116
|
+
const opts = {
|
|
117
|
+
fetch: this.runtime.fetch,
|
|
118
|
+
hostname: host,
|
|
119
|
+
port,
|
|
120
|
+
};
|
|
121
|
+
if (port !== 443) {
|
|
122
|
+
this.logger.info('Creating HTTP server', { port });
|
|
123
|
+
opts.createServer = http.createServer;
|
|
124
|
+
this.server = createAdaptorServer(opts);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
this.logger.info('Creating HTTPS server', { port });
|
|
128
|
+
opts.createServer = https.createServer;
|
|
129
|
+
opts.serverOptions = await this.serverSSLCertLoader.exec(undefined);
|
|
130
|
+
this.server = createAdaptorServer(opts);
|
|
131
|
+
}
|
|
132
|
+
toReq(c) {
|
|
133
|
+
return {
|
|
134
|
+
bodyFromFormData: async () => fromFormData(await c.req.formData()),
|
|
135
|
+
bodyFromJSON: () => c.req.json(),
|
|
136
|
+
bodyFromQueryParams: async () => c.req.queries(),
|
|
137
|
+
bodyRaw: c.req.raw,
|
|
138
|
+
cookie: async (name) => getCookie(c, name),
|
|
139
|
+
header: async (name) => c.req.header(name),
|
|
140
|
+
method: c.req.method,
|
|
141
|
+
secure: c.req.url.startsWith('https://'),
|
|
142
|
+
url: c.req.url,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
toRes(c) {
|
|
146
|
+
return {
|
|
147
|
+
clearCookie: async (name) => {
|
|
148
|
+
deleteCookie(c, name);
|
|
149
|
+
},
|
|
150
|
+
redirect: async (location) => {
|
|
151
|
+
c.redirect(location);
|
|
152
|
+
},
|
|
153
|
+
setCookie: async ({ name, opts, val }) => setCookie(c, name, val, opts),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
NodeHonoServerManager = __decorate([
|
|
158
|
+
injectable(),
|
|
159
|
+
__param(0, inject(EntrypointsBuilder)),
|
|
160
|
+
__param(1, inject('EnvironmentManager')),
|
|
161
|
+
__param(2, inject('Logger')),
|
|
162
|
+
__param(3, inject(ServerRequestHandler)),
|
|
163
|
+
__param(4, inject(ServerSSLCertLoader)),
|
|
164
|
+
__param(5, inject('SettingsManager')),
|
|
165
|
+
__param(6, inject('UCManager')),
|
|
166
|
+
__metadata("design:paramtypes", [EntrypointsBuilder, Object, Object, ServerRequestHandler,
|
|
167
|
+
ServerSSLCertLoader, Object, Object])
|
|
168
|
+
], NodeHonoServerManager);
|
|
169
|
+
export { NodeHonoServerManager };
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libmodulor",
|
|
3
3
|
"description": "A TypeScript library to create business oriented applications",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.13.0",
|
|
5
5
|
"license": "LGPL-3.0",
|
|
6
6
|
"author": "Chafik H'nini <chafik.hnini@gmail.com>",
|
|
7
|
-
"homepage": "https://
|
|
7
|
+
"homepage": "https://libmodulor.c100k.eu",
|
|
8
8
|
"bugs": "https://github.com/c100k/libmodulor/issues",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"library",
|
|
@@ -35,6 +35,9 @@
|
|
|
35
35
|
"./node-express": {
|
|
36
36
|
"import": "./dist/esm/index.node-express.js"
|
|
37
37
|
},
|
|
38
|
+
"./node-hono": {
|
|
39
|
+
"import": "./dist/esm/index.node-hono.js"
|
|
40
|
+
},
|
|
38
41
|
"./node-mcp": {
|
|
39
42
|
"import": "./dist/esm/index.node-mcp.js"
|
|
40
43
|
},
|
|
@@ -78,28 +81,28 @@
|
|
|
78
81
|
"@biomejs/biome": "^1.9.4"
|
|
79
82
|
},
|
|
80
83
|
"peerDependencies": {
|
|
81
|
-
"@hono/node-server": "^1.14.
|
|
82
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
84
|
+
"@hono/node-server": "^1.14.1",
|
|
85
|
+
"@modelcontextprotocol/sdk": "^1.10.1",
|
|
83
86
|
"@stricli/core": "^1.1.2",
|
|
84
87
|
"buffer": "^6.0.3",
|
|
85
88
|
"cookie-parser": "^1.4.7",
|
|
86
89
|
"express": "^5.1.0",
|
|
87
90
|
"express-fileupload": "^1.5.1",
|
|
88
|
-
"fast-check": "^4.1.
|
|
91
|
+
"fast-check": "^4.1.1",
|
|
89
92
|
"helmet": "^8.1.0",
|
|
90
|
-
"hono": "^4.7.
|
|
91
|
-
"inversify": "^7.5.
|
|
93
|
+
"hono": "^4.7.7",
|
|
94
|
+
"inversify": "^7.5.1",
|
|
92
95
|
"jose": "^6.0.10",
|
|
93
96
|
"knex": "^3.1.0",
|
|
94
|
-
"next": "^15.3.
|
|
97
|
+
"next": "^15.3.1",
|
|
95
98
|
"pg": "^8.14.1",
|
|
96
99
|
"react": "^19.1.0",
|
|
97
100
|
"react-dom": "^19.1.0",
|
|
98
|
-
"react-native": "^0.
|
|
101
|
+
"react-native": "^0.79.1",
|
|
99
102
|
"reflect-metadata": "^0.2.2",
|
|
100
103
|
"sqlite3": "^5.1.7",
|
|
101
104
|
"typescript": "^5.8.3",
|
|
102
|
-
"vite": "^6.2
|
|
105
|
+
"vite": "^6.3.2",
|
|
103
106
|
"vitest": "^3.1.1"
|
|
104
107
|
},
|
|
105
108
|
"peerDependenciesMeta": {
|