raiton 6.8.2-beta.18 → 6.8.6-beta.21

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 CHANGED
@@ -1,3 +1,23 @@
1
+ ## [6.8.6-beta.21](https://github.com/protorians/raiton/compare/v6.8.3-beta.19...v6.8.6-beta.21) (2026-10-22)
2
+
3
+ ### Bug Fixes
4
+
5
+ * fix:version ([3d9f1bf](https://github.com/protorians/raiton/commit/3d9f1bf1f64e58e729aa92696bc7a3868c621fdd))
6
+ * chore(release): v6.8.4-beta.20 [skip ci] ([3c6074e](https://github.com/protorians/raiton/commit/3c6074e47a6d399f67eebc624fc13275f88b5403))
7
+ * fix(framework): détecte la véritable adresse LAN du serveur ([c5583a6](https://github.com/protorians/raiton/commit/c5583a6b5083280a9c5fe9fa015286c7085a9453))
8
+
9
+ ## [6.8.4-beta.20](https://github.com/protorians/raiton/compare/v6.8.3-beta.19...v6.8.4-beta.20) (2026-10-22)
10
+
11
+ ### Bug Fixes
12
+
13
+ * fix(framework): détecte la véritable adresse LAN du serveur ([c5583a6](https://github.com/protorians/raiton/commit/c5583a6b5083280a9c5fe9fa015286c7085a9453))
14
+
15
+ ## [6.8.3-beta.19](https://github.com/protorians/raiton/compare/v6.8.2-beta.18...v6.8.3-beta.19) (2026-10-10)
16
+
17
+ ### Bug Fixes
18
+
19
+ * fix(framework): DataTransferObject tolère un corps absent ([13926ab](https://github.com/protorians/raiton/commit/13926ab9f45aaa56a27b46ffc1e923a2876f6ad1))
20
+
1
21
  ## [6.8.2-beta.18](https://github.com/protorians/raiton/compare/v6.8.1-beta.17...v6.8.2-beta.18) (2026-10-08)
2
22
 
3
23
  ### Bug Fixes
@@ -3125,69 +3125,6 @@ Expecting one of '${allowedValues.join("', '")}'`);
3125
3125
  exports.useColor = useColor;
3126
3126
  });
3127
3127
 
3128
- // node_modules/commander/index.js
3129
- var exports_commander = {};
3130
- __exportCjs(exports_commander, {
3131
- program: () => $program,
3132
- createCommand: () => $createCommand,
3133
- createOption: () => $createOption,
3134
- createArgument: () => $createArgument,
3135
- Command: () => $Command,
3136
- Option: () => $Option,
3137
- Argument: () => $Argument,
3138
- Help: () => $Help,
3139
- CommanderError: () => $CommanderError,
3140
- InvalidArgumentError: () => $InvalidArgumentError,
3141
- InvalidOptionArgumentError: () => $InvalidOptionArgumentError
3142
- }, {
3143
- program: (value) => $program = value,
3144
- createCommand: (value) => $createCommand = value,
3145
- createOption: (value) => $createOption = value,
3146
- createArgument: (value) => $createArgument = value,
3147
- Command: (value) => $Command = value,
3148
- Option: (value) => $Option = value,
3149
- Argument: (value) => $Argument = value,
3150
- Help: (value) => $Help = value,
3151
- CommanderError: (value) => $CommanderError = value,
3152
- InvalidArgumentError: (value) => $InvalidArgumentError = value,
3153
- InvalidOptionArgumentError: (value) => $InvalidOptionArgumentError = value
3154
- });
3155
- var Argument, Command, CommanderError, InvalidArgumentError, Help, Option, $program, $createCommand = (name) => new Command(name), $createOption = (flags, description) => new Option(flags, description), $createArgument = (name, description) => new Argument(name, description), $Command, $Option, $Argument, $Help, $CommanderError, $InvalidArgumentError, $InvalidOptionArgumentError;
3156
- var init_commander = __esm(() => {
3157
- ({ Argument } = require_argument());
3158
- ({ Command } = require_command());
3159
- ({ CommanderError, InvalidArgumentError } = require_error());
3160
- ({ Help } = require_help());
3161
- ({ Option } = require_option());
3162
- $program = new Command;
3163
- $Command = Command;
3164
- $Option = Option;
3165
- $Argument = Argument;
3166
- $Help = Help;
3167
- $CommanderError = CommanderError;
3168
- $InvalidArgumentError = InvalidArgumentError;
3169
- $InvalidOptionArgumentError = InvalidArgumentError;
3170
- });
3171
-
3172
- // node_modules/commander/esm.mjs
3173
- var program, createCommand, createArgument, createOption, CommanderError2, InvalidArgumentError2, InvalidOptionArgumentError, Command2, Argument2, Option2, Help2;
3174
- var init_esm = __esm(() => {
3175
- init_commander();
3176
- ({
3177
- program,
3178
- createCommand,
3179
- createArgument,
3180
- createOption,
3181
- CommanderError: CommanderError2,
3182
- InvalidArgumentError: InvalidArgumentError2,
3183
- InvalidOptionArgumentError,
3184
- Command: Command2,
3185
- Argument: Argument2,
3186
- Option: Option2,
3187
- Help: Help2
3188
- } = exports_commander);
3189
- });
3190
-
3191
3128
  // node_modules/@protorians/core/build/index.mjs
3192
3129
  function consoleColorizeLevel(text, level, enabled = true) {
3193
3130
  if (!enabled || level === "SILENT")
@@ -24890,9 +24827,37 @@ var init_constants2 = __esm(() => {
24890
24827
  isNodeUsed = !isBunUsed && !isDenoUsed;
24891
24828
  });
24892
24829
 
24893
- // source/core/thread.ts
24894
- 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 = () => {};
24895
24859
 
24860
+ // source/core/thread.ts
24896
24861
  class RaitonThread {
24897
24862
  builder;
24898
24863
  _options;
@@ -24939,15 +24904,7 @@ class RaitonThread {
24939
24904
  return await until(condition);
24940
24905
  }
24941
24906
  getNetworkIp() {
24942
- const interfaces = os.networkInterfaces();
24943
- for (const name of Object.keys(interfaces)) {
24944
- for (const iface of interfaces[name] || []) {
24945
- if (iface.family === "IPv4" && !iface.internal) {
24946
- return iface.address;
24947
- }
24948
- }
24949
- }
24950
- return null;
24907
+ return getLanIp() ?? null;
24951
24908
  }
24952
24909
  setup({ application, runtime }) {
24953
24910
  const defaultRuntime = isBunUsed ? "bun" /* Bun */ : isDenoUsed ? "deno" /* Deno */ : "node" /* Node */;
@@ -25020,6 +24977,7 @@ var init_thread = __esm(() => {
25020
24977
  init_injection();
25021
24978
  init_exceptions();
25022
24979
  init_constants2();
24980
+ init_ip_util();
25023
24981
  });
25024
24982
 
25025
24983
  // source/framework/mcp/protocol.ts
@@ -26160,7 +26118,7 @@ var init_mcp2 = __esm(() => {
26160
26118
  // source/framework/data-transfer-object.ts
26161
26119
  class DataTransferObject {
26162
26120
  constructor(initial) {
26163
- for (const [key, value] of Object.entries(initial)) {
26121
+ for (const [key, value] of Object.entries(initial ?? {})) {
26164
26122
  if (typeof value !== "function")
26165
26123
  this[key] = value;
26166
26124
  }
@@ -26817,17 +26775,10 @@ var init_openapi_utils = __esm(() => {
26817
26775
  init_thread();
26818
26776
  });
26819
26777
 
26820
- // source/framework/utilities/ip.util.ts
26821
- var getRealIp = (headers, remoteAddress) => {
26822
- const forwardedFor = headers.get("x-forwarded-for");
26823
- if (forwardedFor) {
26824
- return forwardedFor.split(",")[0].trim();
26825
- }
26826
- return headers.get("x-real-ip") || remoteAddress;
26827
- };
26828
-
26829
26778
  // source/framework/utilities/https.util.ts
26830
- var init_https_util = () => {};
26779
+ var init_https_util = __esm(() => {
26780
+ init_ip_util();
26781
+ });
26831
26782
 
26832
26783
  // source/framework/utilities/index.ts
26833
26784
  var init_utilities = __esm(() => {
@@ -26835,6 +26786,7 @@ var init_utilities = __esm(() => {
26835
26786
  init_json_util();
26836
26787
  init_path_util();
26837
26788
  init_openapi_utils();
26789
+ init_ip_util();
26838
26790
  init_https_util();
26839
26791
  init_csrf_util();
26840
26792
  });
@@ -30079,15 +30031,73 @@ var init_core = __esm(() => {
30079
30031
  init_router2();
30080
30032
  });
30081
30033
 
30034
+ // node_modules/commander/index.js
30035
+ var exports_commander = {};
30036
+ __exportCjs(exports_commander, {
30037
+ program: () => $program,
30038
+ createCommand: () => $createCommand,
30039
+ createOption: () => $createOption,
30040
+ createArgument: () => $createArgument,
30041
+ Command: () => $Command,
30042
+ Option: () => $Option,
30043
+ Argument: () => $Argument,
30044
+ Help: () => $Help,
30045
+ CommanderError: () => $CommanderError,
30046
+ InvalidArgumentError: () => $InvalidArgumentError,
30047
+ InvalidOptionArgumentError: () => $InvalidOptionArgumentError
30048
+ }, {
30049
+ program: (value) => $program = value,
30050
+ createCommand: (value) => $createCommand = value,
30051
+ createOption: (value) => $createOption = value,
30052
+ createArgument: (value) => $createArgument = value,
30053
+ Command: (value) => $Command = value,
30054
+ Option: (value) => $Option = value,
30055
+ Argument: (value) => $Argument = value,
30056
+ Help: (value) => $Help = value,
30057
+ CommanderError: (value) => $CommanderError = value,
30058
+ InvalidArgumentError: (value) => $InvalidArgumentError = value,
30059
+ InvalidOptionArgumentError: (value) => $InvalidOptionArgumentError = value
30060
+ });
30061
+
30082
30062
  // source/bin/index.ts
30083
30063
  var import_reflect_metadata15 = __toESM(require_Reflect(), 1);
30084
30064
 
30085
- // source/bin/cli.ts
30086
- init_esm();
30065
+ // node_modules/commander/index.js
30066
+ var { Argument } = require_argument();
30067
+ var { Command } = require_command();
30068
+ var { CommanderError, InvalidArgumentError } = require_error();
30069
+ var { Help } = require_help();
30070
+ var { Option } = require_option();
30071
+ var $program = new Command;
30072
+ var $createCommand = (name) => new Command(name);
30073
+ var $createOption = (flags, description) => new Option(flags, description);
30074
+ var $createArgument = (name, description) => new Argument(name, description);
30075
+ var $Command = Command;
30076
+ var $Option = Option;
30077
+ var $Argument = Argument;
30078
+ var $Help = Help;
30079
+ var $CommanderError = CommanderError;
30080
+ var $InvalidArgumentError = InvalidArgumentError;
30081
+ var $InvalidOptionArgumentError = InvalidArgumentError;
30082
+
30083
+ // node_modules/commander/esm.mjs
30084
+ var {
30085
+ program,
30086
+ createCommand,
30087
+ createArgument,
30088
+ createOption,
30089
+ CommanderError: CommanderError2,
30090
+ InvalidArgumentError: InvalidArgumentError2,
30091
+ InvalidOptionArgumentError,
30092
+ Command: Command2,
30093
+ Argument: Argument2,
30094
+ Option: Option2,
30095
+ Help: Help2
30096
+ } = exports_commander;
30087
30097
  // package.json
30088
30098
  var package_default = {
30089
30099
  name: "raiton",
30090
- version: "6.8.2-beta.18",
30100
+ version: "6.8.6-beta.21",
30091
30101
  private: false,
30092
30102
  type: "module",
30093
30103
  description: "Modular TypeScript Backend Framework with Dependency Injection, Plugins, Controllers, Middleware and Hot Reloading",
@@ -86,6 +86,17 @@ async function handler(context: any) {
86
86
  }
87
87
  ```
88
88
 
89
+ #### DTO de corps
90
+
91
+ Pour un argument `@Body()` typé par une classe, `collectRouteArguments` fait
92
+ `new metatype(ctx.req.body)`. Le DTO doit hériter de `DataTransferObject`, dont
93
+ le constructeur recopie le corps sur l’instance et tolère un corps absent
94
+ (`{}` par défaut) — inutile d’écrire `constructor(data) { super(data ?? {}) }`.
95
+
96
+ `validateDtoArguments` valide ensuite les arguments `instanceof
97
+ DataTransferObject` (via `validation(false)`). Les autres arguments injectés
98
+ (`req`, `params`, `query`, en-têtes…) ne sont pas validés.
99
+
89
100
  ## Exemple de routage manuel
90
101
 
91
102
  ```typescript
@@ -24,10 +24,37 @@ Le plugin est généralement activé automatiquement, mais vous pouvez le docume
24
24
  app.register(bodyParserPlugin())
25
25
  ```
26
26
 
27
+ ## `@Body()` et DTOs
28
+
29
+ Le body parser remplit `context.req.body` avec la charge utile parsée. Ensuite,
30
+ le routeur instancie le type déclaré sur l’argument `@Body()`. Le DTO doit
31
+ hériter de `DataTransferObject`, qui recopie le corps sur l’instance.
32
+
33
+ ```typescript
34
+ import { Body, Controllable, Post, DataTransferObject } from "raiton/framework"
35
+
36
+ class CreateUserDto extends DataTransferObject {
37
+ name!: string
38
+ }
39
+
40
+ @Controllable("/users")
41
+ export class UsersController {
42
+ @Post("/")
43
+ create(@Body() payload: CreateUserDto) {
44
+ // payload.name est renseigné
45
+ return payload
46
+ }
47
+ }
48
+ ```
49
+
50
+ Un `POST` sans corps produit un DTO vide (`{}`) plutôt qu’une erreur, sans
51
+ constructeur à écrire dans le DTO.
52
+
27
53
  ## Avantages
28
54
 
29
55
  - rend les payloads utilisables directement dans les contrôleurs
30
56
  - gère plusieurs formats courants
57
+ - DTOs `@Body()` hydratés via `DataTransferObject`
31
58
 
32
59
  ## Inconvénients
33
60
 
@@ -31,6 +31,38 @@ export class UsersController {
31
31
  }
32
32
  ```
33
33
 
34
+ ## DTOs et validation
35
+
36
+ Un DTO doit **toujours** hériter de `DataTransferObject` (`raiton/framework`).
37
+ Le routeur instancie le type de l’argument `@Body()` et lui passe le corps
38
+ parsé ; `DataTransferObject` recopie alors ses champs. La validation
39
+ `class-validator` s’exécute automatiquement avant l’appel du handler.
40
+
41
+ ```typescript
42
+ import { IsNotEmpty, IsString } from "class-validator"
43
+ import { ApiBody, Body, Controllable, Post, DataTransferObject } from "raiton/framework"
44
+
45
+ class CreateUserDto extends DataTransferObject {
46
+ @IsString()
47
+ @IsNotEmpty()
48
+ name!: string
49
+ }
50
+
51
+ @Controllable("/users")
52
+ export class UsersController {
53
+ @Post("/")
54
+ @ApiBody({ type: CreateUserDto })
55
+ create(@Body() payload: CreateUserDto) {
56
+ return payload
57
+ }
58
+ }
59
+ ```
60
+
61
+ - **Ne définissez pas de constructeur** dans le DTO : `DataTransferObject` gère
62
+ déjà la copie du corps et tolère un corps absent (DTO vide). Écrire
63
+ `constructor(data) { super(data ?? {}) }` est inutile.
64
+ - Le DTO expose `payload.validation()` pour une validation manuelle.
65
+
34
66
  ## Avantages
35
67
 
36
68
  - contrats d’entrée plus clairs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "raiton",
3
- "version": "6.8.2-beta.18",
3
+ "version": "6.8.6-beta.21",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Modular TypeScript Backend Framework with Dependency Injection, Plugins, Controllers, Middleware and Hot Reloading",
@@ -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 os from "os";
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
- const interfaces = os.networkInterfaces();
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 {
@@ -3,8 +3,10 @@ import {Logger} from "@protorians/logger";
3
3
 
4
4
 
5
5
  export class DataTransferObject {
6
- constructor(initial: Record<string, any>) {
7
- for (const [key, value] of Object.entries(initial)) {
6
+ constructor(initial?: Record<string, any>) {
7
+ // `?? {}` : un corps absent (POST sans payload) donne un DTO vide plutôt
8
+ // qu'un `TypeError` sur `Object.entries(undefined)`.
9
+ for (const [key, value] of Object.entries(initial ?? {})) {
8
10
  if (typeof value !== 'function') this[key as keyof typeof this] = value;
9
11
  }
10
12
  }
@@ -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
- const interfaces = os.networkInterfaces()
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
+ }