raiton 6.8.3-beta.19 → 6.8.8-beta.24
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 +27 -0
- package/build/bin/index.mjs +61 -23
- package/package.json +2 -1
- package/source/core/controller/builder.ts +42 -1
- package/source/core/thread.ts +2 -10
- package/source/framework/utilities/https.util.ts +2 -10
- package/source/framework/utilities/ip.util.ts +34 -0
- package/tests/artifact-resolution.test.ts +60 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
## [6.8.8-beta.24](https://github.com/protorians/raiton/compare/v6.8.7-beta.22...v6.8.8-beta.24) (2026-10-30)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* fix:version ([66e4a81](https://github.com/protorians/raiton/commit/66e4a81d212a72fbcc947775d97ef20f09ac5989))
|
|
6
|
+
|
|
7
|
+
## [6.8.7-beta.22](https://github.com/protorians/raiton/compare/v6.8.6-beta.21...v6.8.7-beta.22) (2026-10-30)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* chore(test): ajoute le script test (bun test) ([4b25595](https://github.com/protorians/raiton/commit/4b2559542894fed96ba6deef38427f197d3e5da9))
|
|
12
|
+
* fix(core): retrouve l'artefact décoré parmi les exports nommés ([3f60b91](https://github.com/protorians/raiton/commit/3f60b914851cd920b96376d04be3efde9f968a95))
|
|
13
|
+
|
|
14
|
+
## [6.8.6-beta.21](https://github.com/protorians/raiton/compare/v6.8.3-beta.19...v6.8.6-beta.21) (2026-10-22)
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* fix:version ([3d9f1bf](https://github.com/protorians/raiton/commit/3d9f1bf1f64e58e729aa92696bc7a3868c621fdd))
|
|
19
|
+
* chore(release): v6.8.4-beta.20 [skip ci] ([3c6074e](https://github.com/protorians/raiton/commit/3c6074e47a6d399f67eebc624fc13275f88b5403))
|
|
20
|
+
* fix(framework): détecte la véritable adresse LAN du serveur ([c5583a6](https://github.com/protorians/raiton/commit/c5583a6b5083280a9c5fe9fa015286c7085a9453))
|
|
21
|
+
|
|
22
|
+
## [6.8.4-beta.20](https://github.com/protorians/raiton/compare/v6.8.3-beta.19...v6.8.4-beta.20) (2026-10-22)
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* fix(framework): détecte la véritable adresse LAN du serveur ([c5583a6](https://github.com/protorians/raiton/commit/c5583a6b5083280a9c5fe9fa015286c7085a9453))
|
|
27
|
+
|
|
1
28
|
## [6.8.3-beta.19](https://github.com/protorians/raiton/compare/v6.8.2-beta.18...v6.8.3-beta.19) (2026-10-10)
|
|
2
29
|
|
|
3
30
|
### Bug Fixes
|
package/build/bin/index.mjs
CHANGED
|
@@ -24827,9 +24827,37 @@ var init_constants2 = __esm(() => {
|
|
|
24827
24827
|
isNodeUsed = !isBunUsed && !isDenoUsed;
|
|
24828
24828
|
});
|
|
24829
24829
|
|
|
24830
|
-
// source/
|
|
24831
|
-
import os from "os";
|
|
24830
|
+
// source/framework/utilities/ip.util.ts
|
|
24831
|
+
import os from "node:os";
|
|
24832
|
+
var getRealIp = (headers, remoteAddress) => {
|
|
24833
|
+
const forwardedFor = headers.get("x-forwarded-for");
|
|
24834
|
+
if (forwardedFor) {
|
|
24835
|
+
return forwardedFor.split(",")[0].trim();
|
|
24836
|
+
}
|
|
24837
|
+
return headers.get("x-real-ip") || remoteAddress;
|
|
24838
|
+
}, getLanIp = () => {
|
|
24839
|
+
const candidates = [];
|
|
24840
|
+
for (const [name, addrs] of Object.entries(os.networkInterfaces())) {
|
|
24841
|
+
for (const addr of addrs || []) {
|
|
24842
|
+
if (addr.family !== "IPv4" || addr.internal)
|
|
24843
|
+
continue;
|
|
24844
|
+
if (addr.address.startsWith("169.254."))
|
|
24845
|
+
continue;
|
|
24846
|
+
let score = 0;
|
|
24847
|
+
if (/^(?:10\.|192\.168\.|172\.(?:1[6-9]|2\d|3[01])\.)/.test(addr.address))
|
|
24848
|
+
score += 4;
|
|
24849
|
+
if (/^(utun|awdl|llw|bridge|vmnet|docker|veth|tun|tap|ppp)/.test(name))
|
|
24850
|
+
score -= 2;
|
|
24851
|
+
if (/^(en|eth|wlan)/.test(name))
|
|
24852
|
+
score += 1;
|
|
24853
|
+
candidates.push({ name, address: addr.address, score });
|
|
24854
|
+
}
|
|
24855
|
+
}
|
|
24856
|
+
return candidates.sort((a, b) => b.score - a.score)[0]?.address;
|
|
24857
|
+
};
|
|
24858
|
+
var init_ip_util = () => {};
|
|
24832
24859
|
|
|
24860
|
+
// source/core/thread.ts
|
|
24833
24861
|
class RaitonThread {
|
|
24834
24862
|
builder;
|
|
24835
24863
|
_options;
|
|
@@ -24876,15 +24904,7 @@ class RaitonThread {
|
|
|
24876
24904
|
return await until(condition);
|
|
24877
24905
|
}
|
|
24878
24906
|
getNetworkIp() {
|
|
24879
|
-
|
|
24880
|
-
for (const name of Object.keys(interfaces)) {
|
|
24881
|
-
for (const iface of interfaces[name] || []) {
|
|
24882
|
-
if (iface.family === "IPv4" && !iface.internal) {
|
|
24883
|
-
return iface.address;
|
|
24884
|
-
}
|
|
24885
|
-
}
|
|
24886
|
-
}
|
|
24887
|
-
return null;
|
|
24907
|
+
return getLanIp() ?? null;
|
|
24888
24908
|
}
|
|
24889
24909
|
setup({ application, runtime }) {
|
|
24890
24910
|
const defaultRuntime = isBunUsed ? "bun" /* Bun */ : isDenoUsed ? "deno" /* Deno */ : "node" /* Node */;
|
|
@@ -24957,6 +24977,7 @@ var init_thread = __esm(() => {
|
|
|
24957
24977
|
init_injection();
|
|
24958
24978
|
init_exceptions();
|
|
24959
24979
|
init_constants2();
|
|
24980
|
+
init_ip_util();
|
|
24960
24981
|
});
|
|
24961
24982
|
|
|
24962
24983
|
// source/framework/mcp/protocol.ts
|
|
@@ -25637,7 +25658,7 @@ class ControllerBuilder {
|
|
|
25637
25658
|
if (!isController && !isSocket && !isMcp && !isScheduler)
|
|
25638
25659
|
return;
|
|
25639
25660
|
const imported = await import(`${filename}?v=${version || 1}&t=${timestamp || Date.now()}`);
|
|
25640
|
-
const artifact = imported
|
|
25661
|
+
const artifact = resolveArtifact(imported, { isController, isSocket, isMcp, isScheduler });
|
|
25641
25662
|
if (!artifact)
|
|
25642
25663
|
return;
|
|
25643
25664
|
if (!RaitonThread.current?.application)
|
|
@@ -25677,6 +25698,27 @@ class ControllerBuilder {
|
|
|
25677
25698
|
}
|
|
25678
25699
|
}
|
|
25679
25700
|
}
|
|
25701
|
+
function resolveArtifact(imported, kinds) {
|
|
25702
|
+
if (!imported || typeof imported !== "object")
|
|
25703
|
+
return imported;
|
|
25704
|
+
const keys = [];
|
|
25705
|
+
if (kinds.isController)
|
|
25706
|
+
keys.push(METADATA_KEYS.CONTROLLERS);
|
|
25707
|
+
if (kinds.isSocket)
|
|
25708
|
+
keys.push(METADATA_KEYS.SOCKETS);
|
|
25709
|
+
if (kinds.isMcp)
|
|
25710
|
+
keys.push(METADATA_KEYS.MCP);
|
|
25711
|
+
if (kinds.isScheduler)
|
|
25712
|
+
keys.push(METADATA_KEYS.SCHEDULER);
|
|
25713
|
+
const decorated = Object.values(imported).find((candidate) => isDecoratedArtifact(candidate, keys));
|
|
25714
|
+
return decorated ?? imported.default ?? imported;
|
|
25715
|
+
}
|
|
25716
|
+
function isDecoratedArtifact(candidate, keys) {
|
|
25717
|
+
if (typeof candidate !== "function")
|
|
25718
|
+
return false;
|
|
25719
|
+
const prototype = candidate.prototype;
|
|
25720
|
+
return keys.some((key) => (prototype ? Boolean(Reflect.getMetadata(key, prototype)) : false) || Boolean(Reflect.getMetadata(key, candidate)));
|
|
25721
|
+
}
|
|
25680
25722
|
var init_builder4 = __esm(() => {
|
|
25681
25723
|
init_compiler();
|
|
25682
25724
|
init_builder();
|
|
@@ -25686,6 +25728,7 @@ var init_builder4 = __esm(() => {
|
|
|
25686
25728
|
init_injection2();
|
|
25687
25729
|
init_framework();
|
|
25688
25730
|
init_artifacts();
|
|
25731
|
+
init_constants();
|
|
25689
25732
|
init_tracker();
|
|
25690
25733
|
});
|
|
25691
25734
|
|
|
@@ -26754,17 +26797,10 @@ var init_openapi_utils = __esm(() => {
|
|
|
26754
26797
|
init_thread();
|
|
26755
26798
|
});
|
|
26756
26799
|
|
|
26757
|
-
// source/framework/utilities/ip.util.ts
|
|
26758
|
-
var getRealIp = (headers, remoteAddress) => {
|
|
26759
|
-
const forwardedFor = headers.get("x-forwarded-for");
|
|
26760
|
-
if (forwardedFor) {
|
|
26761
|
-
return forwardedFor.split(",")[0].trim();
|
|
26762
|
-
}
|
|
26763
|
-
return headers.get("x-real-ip") || remoteAddress;
|
|
26764
|
-
};
|
|
26765
|
-
|
|
26766
26800
|
// source/framework/utilities/https.util.ts
|
|
26767
|
-
var init_https_util = () => {
|
|
26801
|
+
var init_https_util = __esm(() => {
|
|
26802
|
+
init_ip_util();
|
|
26803
|
+
});
|
|
26768
26804
|
|
|
26769
26805
|
// source/framework/utilities/index.ts
|
|
26770
26806
|
var init_utilities = __esm(() => {
|
|
@@ -26772,6 +26808,7 @@ var init_utilities = __esm(() => {
|
|
|
26772
26808
|
init_json_util();
|
|
26773
26809
|
init_path_util();
|
|
26774
26810
|
init_openapi_utils();
|
|
26811
|
+
init_ip_util();
|
|
26775
26812
|
init_https_util();
|
|
26776
26813
|
init_csrf_util();
|
|
26777
26814
|
});
|
|
@@ -30082,7 +30119,7 @@ var {
|
|
|
30082
30119
|
// package.json
|
|
30083
30120
|
var package_default = {
|
|
30084
30121
|
name: "raiton",
|
|
30085
|
-
version: "6.8.
|
|
30122
|
+
version: "6.8.8-beta.24",
|
|
30086
30123
|
private: false,
|
|
30087
30124
|
type: "module",
|
|
30088
30125
|
description: "Modular TypeScript Backend Framework with Dependency Injection, Plugins, Controllers, Middleware and Hot Reloading",
|
|
@@ -30123,6 +30160,7 @@ var package_default = {
|
|
|
30123
30160
|
"dev:node": "node build/bin/index.mjs dev",
|
|
30124
30161
|
"dev:deno": "deno task dev",
|
|
30125
30162
|
build: "bun build source/bin/index.ts --target=node --format=esm --outfile=build/bin/index.mjs",
|
|
30163
|
+
test: "bun test tests",
|
|
30126
30164
|
start: "bun run source/bin/index.ts start",
|
|
30127
30165
|
"start:node": "node build/bin/index.mjs start",
|
|
30128
30166
|
"start:deno": "deno task start",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "raiton",
|
|
3
|
-
"version": "6.8.
|
|
3
|
+
"version": "6.8.8-beta.24",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Modular TypeScript Backend Framework with Dependency Injection, Plugins, Controllers, Middleware and Hot Reloading",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"dev:node": "node build/bin/index.mjs dev",
|
|
42
42
|
"dev:deno": "deno task dev",
|
|
43
43
|
"build": "bun build source/bin/index.ts --target=node --format=esm --outfile=build/bin/index.mjs",
|
|
44
|
+
"test": "bun test tests",
|
|
44
45
|
"start": "bun run source/bin/index.ts start",
|
|
45
46
|
"start:node": "node build/bin/index.mjs start",
|
|
46
47
|
"start:deno": "deno task start",
|
|
@@ -9,6 +9,7 @@ import {RaitonThread} from "../thread.ts";
|
|
|
9
9
|
import {Injection} from "../injection/index.ts";
|
|
10
10
|
import {isControllerArtifact, isSocketArtifact, isMcpArtifact, isSchedulerArtifact} from "../../framework/index.ts";
|
|
11
11
|
import {Artifacts} from "../../framework/artifacts.ts";
|
|
12
|
+
import {METADATA_KEYS} from "../../framework/constants/index.ts";
|
|
12
13
|
import path from "node:path";
|
|
13
14
|
import {ControllerRouteTracker} from "./tracker.ts";
|
|
14
15
|
|
|
@@ -58,7 +59,7 @@ export class ControllerBuilder {
|
|
|
58
59
|
return undefined;
|
|
59
60
|
|
|
60
61
|
const imported = await import(`${filename}?v=${version || 1}&t=${timestamp || Date.now()}`)
|
|
61
|
-
const artifact = imported
|
|
62
|
+
const artifact = resolveArtifact(imported, {isController, isSocket, isMcp, isScheduler});
|
|
62
63
|
|
|
63
64
|
if (!artifact) return undefined;
|
|
64
65
|
if (!RaitonThread.current?.application) return undefined;
|
|
@@ -104,3 +105,43 @@ export class ControllerBuilder {
|
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
}
|
|
108
|
+
|
|
109
|
+
interface ArtifactKinds {
|
|
110
|
+
isController: boolean;
|
|
111
|
+
isSocket: boolean;
|
|
112
|
+
isMcp: boolean;
|
|
113
|
+
isScheduler: boolean;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Sélectionne la classe réellement décorée parmi les exports d'un fichier
|
|
117
|
+
* d'artefact.
|
|
118
|
+
*
|
|
119
|
+
* Les fichiers peuvent exporter leur artefact en `default` **ou** en export
|
|
120
|
+
* nommé (les exemples de la documentation Raiton utilisent `export class
|
|
121
|
+
* MathServer`). L'ancien `imported.default || imported` retombait sur l'objet
|
|
122
|
+
* namespace du module pour un export nommé : `compileMcp` enregistrait alors un
|
|
123
|
+
* serveur fantôme (nom et métadonnées vides) sur le même chemin HTTP.
|
|
124
|
+
*/
|
|
125
|
+
export function resolveArtifact(imported: any, kinds: ArtifactKinds): any {
|
|
126
|
+
if (!imported || typeof imported !== 'object') return imported;
|
|
127
|
+
|
|
128
|
+
const keys: symbol[] = [];
|
|
129
|
+
if (kinds.isController) keys.push(METADATA_KEYS.CONTROLLERS);
|
|
130
|
+
if (kinds.isSocket) keys.push(METADATA_KEYS.SOCKETS);
|
|
131
|
+
if (kinds.isMcp) keys.push(METADATA_KEYS.MCP);
|
|
132
|
+
if (kinds.isScheduler) keys.push(METADATA_KEYS.SCHEDULER);
|
|
133
|
+
|
|
134
|
+
const decorated = Object.values(imported)
|
|
135
|
+
.find((candidate) => isDecoratedArtifact(candidate, keys));
|
|
136
|
+
|
|
137
|
+
return decorated ?? imported.default ?? imported;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function isDecoratedArtifact(candidate: any, keys: symbol[]): boolean {
|
|
141
|
+
if (typeof candidate !== 'function') return false;
|
|
142
|
+
const prototype = candidate.prototype;
|
|
143
|
+
return keys.some((key) =>
|
|
144
|
+
(prototype ? Boolean(Reflect.getMetadata(key, prototype)) : false)
|
|
145
|
+
|| Boolean(Reflect.getMetadata(key, candidate)),
|
|
146
|
+
);
|
|
147
|
+
}
|
package/source/core/thread.ts
CHANGED
|
@@ -21,7 +21,7 @@ import {bodyParserPlugin} from "../framework/plugins/body-parser.plugin.ts";
|
|
|
21
21
|
import {Injection} from "./injection/injection.ts";
|
|
22
22
|
import {Throwable} from "../framework/exceptions/index.ts";
|
|
23
23
|
import {isBunUsed, isDenoUsed, isNodeUsed} from "../bin/constants.ts";
|
|
24
|
-
import
|
|
24
|
+
import {getLanIp} from "../framework/utilities/ip.util.ts";
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
export class RaitonThread implements ThreadInterface {
|
|
@@ -80,15 +80,7 @@ export class RaitonThread implements ThreadInterface {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
protected getNetworkIp(): string | null {
|
|
83
|
-
|
|
84
|
-
for (const name of Object.keys(interfaces)) {
|
|
85
|
-
for (const iface of interfaces[name] || []) {
|
|
86
|
-
if (iface.family === 'IPv4' && !iface.internal) {
|
|
87
|
-
return iface.address;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return null;
|
|
83
|
+
return getLanIp() ?? null;
|
|
92
84
|
}
|
|
93
85
|
|
|
94
86
|
public setup({application, runtime}: ThreadSetupOptionsInterface): this {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
|
-
import os from 'node:os'
|
|
3
2
|
import {execSync, execFileSync} from 'node:child_process'
|
|
4
3
|
import path from 'node:path'
|
|
4
|
+
import {getLanIp} from './ip.util.ts'
|
|
5
5
|
|
|
6
6
|
export enum HttpsEnvironment {
|
|
7
7
|
Localhost = 'localhost',
|
|
@@ -77,15 +77,7 @@ function resolveCertFromPaths(
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
function getLanHostname(): string {
|
|
80
|
-
|
|
81
|
-
for (const name of Object.keys(interfaces)) {
|
|
82
|
-
for (const iface of interfaces[name] || []) {
|
|
83
|
-
if (iface.family === 'IPv4' && !iface.internal) {
|
|
84
|
-
return iface.address
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return 'localhost'
|
|
80
|
+
return getLanIp() ?? 'localhost'
|
|
89
81
|
}
|
|
90
82
|
|
|
91
83
|
function isCommandAvailable(command: string): boolean {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import os from 'node:os'
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Get the real IP address from headers or remote address
|
|
3
5
|
* @param headers
|
|
@@ -10,3 +12,35 @@ export const getRealIp = (headers: Headers, remoteAddress?: string): string | un
|
|
|
10
12
|
}
|
|
11
13
|
return headers.get('x-real-ip') || remoteAddress;
|
|
12
14
|
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Get the server's LAN IPv4 address.
|
|
18
|
+
*
|
|
19
|
+
* Prefers private (RFC1918) addresses on physical adapters and skips
|
|
20
|
+
* link-local (169.254.0.0/16) addresses exposed by interfaces without
|
|
21
|
+
* DHCP (en9, awdl0, llw0, utun*, bridges...) so that the first address
|
|
22
|
+
* found is the real one.
|
|
23
|
+
*/
|
|
24
|
+
export const getLanIp = (): string | undefined => {
|
|
25
|
+
const candidates: {name: string; address: string; score: number}[] = [];
|
|
26
|
+
|
|
27
|
+
for (const [name, addrs] of Object.entries(os.networkInterfaces())) {
|
|
28
|
+
for (const addr of addrs || []) {
|
|
29
|
+
if (addr.family !== 'IPv4' || addr.internal) continue;
|
|
30
|
+
// Skip link-local (APIPA) addresses: interfaces without DHCP
|
|
31
|
+
if (addr.address.startsWith('169.254.')) continue;
|
|
32
|
+
|
|
33
|
+
let score = 0;
|
|
34
|
+
// Prefer private (RFC1918) ranges: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
|
|
35
|
+
if (/^(?:10\.|192\.168\.|172\.(?:1[6-9]|2\d|3[01])\.)/.test(addr.address)) score += 4;
|
|
36
|
+
// Deprioritize well-known virtual interfaces
|
|
37
|
+
if (/^(utun|awdl|llw|bridge|vmnet|docker|veth|tun|tap|ppp)/.test(name)) score -= 2;
|
|
38
|
+
// Slightly prefer physical adapters (macOS en*, Linux eth/wlan)
|
|
39
|
+
if (/^(en|eth|wlan)/.test(name)) score += 1;
|
|
40
|
+
|
|
41
|
+
candidates.push({name, address: addr.address, score});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return candidates.sort((a, b) => b.score - a.score)[0]?.address;
|
|
46
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import {describe, expect, it} from "bun:test";
|
|
3
|
+
import {resolveArtifact} from "../source/core/controller/builder.ts";
|
|
4
|
+
import {METADATA_KEYS} from "../source/framework/constants/decorators.constant.ts";
|
|
5
|
+
|
|
6
|
+
const ALL = {isController: false, isSocket: false, isMcp: false, isScheduler: false};
|
|
7
|
+
|
|
8
|
+
function serverMetadata(path = "/mcp") {
|
|
9
|
+
return {
|
|
10
|
+
name: "named-server",
|
|
11
|
+
version: "1.0.0",
|
|
12
|
+
path,
|
|
13
|
+
tools: [],
|
|
14
|
+
prompts: [],
|
|
15
|
+
resources: [],
|
|
16
|
+
resourceTemplates: [],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe("résolution des artefacts exportés", () => {
|
|
21
|
+
it("retrouve un serveur MCP exporté en nommé", () => {
|
|
22
|
+
class MathServer {
|
|
23
|
+
add() {
|
|
24
|
+
return 1;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
Reflect.defineMetadata(METADATA_KEYS.MCP, serverMetadata(), MathServer.prototype);
|
|
29
|
+
|
|
30
|
+
const artifact = resolveArtifact({MathServer}, {...ALL, isMcp: true});
|
|
31
|
+
|
|
32
|
+
expect(artifact).toBe(MathServer);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("retrouve un contrôleur exporté en nommé, même avec d’autres exports", () => {
|
|
36
|
+
class ListUsersController {}
|
|
37
|
+
class Unused {}
|
|
38
|
+
|
|
39
|
+
Reflect.defineMetadata(METADATA_KEYS.CONTROLLERS, {prefix: "/users", routes: [], middlewares: {}}, ListUsersController.prototype);
|
|
40
|
+
|
|
41
|
+
const artifact = resolveArtifact(
|
|
42
|
+
{ListUsersController, Unused, helper: () => undefined},
|
|
43
|
+
{...ALL, isController: true},
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
expect(artifact).toBe(ListUsersController);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("conserve l’export default quand aucun artefact n’est décoré", () => {
|
|
50
|
+
class Plain {}
|
|
51
|
+
|
|
52
|
+
expect(resolveArtifact({default: Plain, other: 1}, {...ALL, isMcp: true})).toBe(Plain);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("retombe sur le module importé quand aucun export n’est exploitable", () => {
|
|
56
|
+
const imported = {helper: () => undefined};
|
|
57
|
+
|
|
58
|
+
expect(resolveArtifact(imported, {...ALL, isMcp: true})).toBe(imported);
|
|
59
|
+
});
|
|
60
|
+
});
|