raiton 5.9.7-beta.18 → 6.0.1-beta.2

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.
Files changed (93) hide show
  1. package/README.md +13 -9
  2. package/build/bin/index.mjs +7 -18
  3. package/docs/README.md +6 -129
  4. package/docs/contributors/README.md +103 -0
  5. package/docs/{cli → contributors/cli}/README.md +1 -1
  6. package/docs/{cli → contributors/cli}/hmr.md +20 -23
  7. package/docs/{core → contributors/core}/README.md +1 -1
  8. package/docs/{core → contributors/core}/builder-thread.md +4 -7
  9. package/docs/{core → contributors/core}/controller.md +1 -1
  10. package/docs/contributors/framework/README.md +67 -0
  11. package/docs/{framework → contributors/framework}/base-classes.md +30 -2
  12. package/docs/{framework → contributors/framework}/decorators/socket.md +31 -3
  13. package/docs/{types → contributors/types}/README.md +1 -1
  14. package/docs/user-guide/README.md +62 -0
  15. package/docs/user-guide/api/README.md +21 -0
  16. package/docs/user-guide/api/example.md +50 -0
  17. package/docs/user-guide/api/responses.md +58 -0
  18. package/docs/user-guide/api/routes.md +56 -0
  19. package/docs/user-guide/architecture.md +83 -0
  20. package/docs/user-guide/best-practices.md +36 -0
  21. package/docs/user-guide/body-parser.md +39 -0
  22. package/docs/user-guide/cli.md +51 -0
  23. package/docs/user-guide/config.md +47 -0
  24. package/docs/user-guide/decorators/README.md +33 -0
  25. package/docs/user-guide/decorators/api-body.md +47 -0
  26. package/docs/user-guide/decorators/api-operation.md +47 -0
  27. package/docs/user-guide/decorators/api-param.md +47 -0
  28. package/docs/user-guide/decorators/api-property.md +46 -0
  29. package/docs/user-guide/decorators/api-query.md +47 -0
  30. package/docs/user-guide/decorators/api-response.md +48 -0
  31. package/docs/user-guide/decorators/api-tags.md +47 -0
  32. package/docs/user-guide/decorators/controllable.md +46 -0
  33. package/docs/user-guide/decorators/guard.md +57 -0
  34. package/docs/user-guide/decorators/injection.md +55 -0
  35. package/docs/user-guide/decorators/middleware.md +56 -0
  36. package/docs/user-guide/decorators/parameters.md +57 -0
  37. package/docs/user-guide/decorators/route-interaction.md +47 -0
  38. package/docs/user-guide/decorators/routes.md +62 -0
  39. package/docs/user-guide/decorators/socket.md +59 -0
  40. package/docs/user-guide/encryption.md +40 -0
  41. package/docs/user-guide/env.md +39 -0
  42. package/docs/user-guide/getting-started.md +72 -0
  43. package/docs/user-guide/injection.md +80 -0
  44. package/docs/user-guide/middleware.md +98 -0
  45. package/docs/user-guide/openapi/README.md +70 -0
  46. package/docs/user-guide/openapi/plugin.md +72 -0
  47. package/docs/user-guide/plugins.md +69 -0
  48. package/docs/user-guide/responses.md +99 -0
  49. package/docs/user-guide/runtime.md +44 -0
  50. package/docs/user-guide/security.md +46 -0
  51. package/docs/user-guide/sockets.md +49 -0
  52. package/docs/user-guide/tutorial.md +175 -0
  53. package/docs/user-guide/types.md +118 -0
  54. package/package.json +1 -1
  55. package/source/commands/build.command.ts +2 -2
  56. package/source/core/builder.ts +15 -14
  57. package/source/core/controller/builder.ts +14 -6
  58. package/source/core/socket/builder.ts +5 -0
  59. package/source/core/socket/index.ts +1 -0
  60. package/source/core/socket/metadata.ts +54 -1
  61. package/source/core/thread.ts +4 -1
  62. package/source/framework/artifacts.ts +2 -12
  63. package/source/framework/constants/decorators.constant.ts +1 -0
  64. package/source/framework/decorators/api-response.decorator.ts +4 -5
  65. package/source/framework/decorators/api.decorator.ts +36 -20
  66. package/source/framework/decorators/socket.decorator.ts +2 -1
  67. package/source/framework/runtime/bun/server.ts +100 -3
  68. package/source/framework/runtime/index.ts +4 -3
  69. package/source/framework/utilities/openapi.utils.ts +154 -109
  70. package/source/types/raiton.ts +2 -2
  71. package/source/types/runtime.ts +5 -1
  72. package/docs/framework/README.md +0 -96
  73. /package/docs/{cli → contributors/cli}/commands.md +0 -0
  74. /package/docs/{core → contributors/core}/application.md +0 -0
  75. /package/docs/{core → contributors/core}/config.md +0 -0
  76. /package/docs/{core → contributors/core}/injection.md +0 -0
  77. /package/docs/{core → contributors/core}/middleware.md +0 -0
  78. /package/docs/{core → contributors/core}/plugin-scope.md +0 -0
  79. /package/docs/{core → contributors/core}/router.md +0 -0
  80. /package/docs/{framework → contributors/framework}/decorators/README.md +0 -0
  81. /package/docs/{framework → contributors/framework}/decorators/controllable.md +0 -0
  82. /package/docs/{framework → contributors/framework}/decorators/injection.md +0 -0
  83. /package/docs/{framework → contributors/framework}/decorators/middleware.md +0 -0
  84. /package/docs/{framework → contributors/framework}/decorators/openapi.md +0 -0
  85. /package/docs/{framework → contributors/framework}/decorators/parametrable.md +0 -0
  86. /package/docs/{framework → contributors/framework}/encryption.md +0 -0
  87. /package/docs/{framework → contributors/framework}/env.md +0 -0
  88. /package/docs/{framework → contributors/framework}/plugins/README.md +0 -0
  89. /package/docs/{framework → contributors/framework}/plugins/body-parser.md +0 -0
  90. /package/docs/{framework → contributors/framework}/plugins/openapi.md +0 -0
  91. /package/docs/{framework → contributors/framework}/plugins/security.md +0 -0
  92. /package/docs/{framework → contributors/framework}/responses.md +0 -0
  93. /package/docs/{framework → contributors/framework}/runtime.md +0 -0
package/README.md CHANGED
@@ -50,23 +50,25 @@ export class HelloController {
50
50
 
51
51
  ```typescript
52
52
  import "reflect-metadata";
53
- import {ThreadInterface} from "raiton/types";
54
- import {Application} from "raiton/core";
53
+ import { ThreadInterface } from "raiton/types";
54
+ import { Application } from "raiton/core";
55
+ import { RuntimeType } from "raiton/framework";
55
56
 
56
- export default async function (thread: ThreadInterface) {
57
+ export default async (thread: ThreadInterface) => {
57
58
  const app = new Application({
58
- port: 3000,
59
+ port: 5711,
59
60
  prefix: '/api'
60
61
  });
61
62
 
62
- // Enregistrez vos plugins, middlewares et contrôleurs ici
63
- // ...
64
-
65
- // Lier son application au thread
66
- return await thread.setup({application: app}).run()
63
+ return await thread.setup({
64
+ application: app,
65
+ runtime: RuntimeType.Bun
66
+ }).run()
67
67
  }
68
68
  ```
69
69
 
70
+ > **Note :** selon la configuration du projet, le bootstrapper est chargé depuis `source/main.ts` et la racine du projet peut être définie par `raiton.config.ts` via `rootDir`.
71
+
70
72
  ## Utilisation du CLI
71
73
 
72
74
  Raiton est livré avec une interface en ligne de commande pour faciliter le développement.
@@ -92,6 +94,8 @@ Raiton détecte automatiquement l'environnement d'exécution et adapte son serve
92
94
 
93
95
  ## Documentation API
94
96
 
97
+ Pour l’usage applicatif, voir le guide développeur : [docs/user-guide/README.md](docs/user-guide/README.md)
98
+
95
99
  Example
96
100
  ```typescript
97
101
  import { Controllable, Get, ApiOkResponse, ApiResponse } from 'raiton/framework';
@@ -4817,7 +4817,7 @@ var {
4817
4817
  Help
4818
4818
  } = import__.default;
4819
4819
  // package.json
4820
- var version = "5.9.7-beta.18";
4820
+ var version = "6.0.1-beta.2";
4821
4821
 
4822
4822
  // source/bin/cli.ts
4823
4823
  var CLI = new Command;
@@ -6212,9 +6212,6 @@ class RaitonConfig {
6212
6212
  }
6213
6213
  }
6214
6214
  // source/framework/utilities/artifact.util.ts
6215
- function isControllerArtifact(filename) {
6216
- return isArtifact(filename, "controller");
6217
- }
6218
6215
  function isArtifact(filename, artifact) {
6219
6216
  return [
6220
6217
  filename.endsWith(`.${artifact}.ts`),
@@ -6261,6 +6258,7 @@ var METADATA_KEYS = {
6261
6258
  API_TAGS: Symbol("api:tags"),
6262
6259
  API_OPERATION: Symbol("api:operation"),
6263
6260
  API_SECURITY: Symbol("api:security"),
6261
+ API_PROPERTY: Symbol("api:property"),
6264
6262
  ROUTE_INTERACTION: Symbol("route:interaction")
6265
6263
  };
6266
6264
  // source/framework/responses/http.ts
@@ -6738,6 +6736,9 @@ class Injection {
6738
6736
  return this.get(name);
6739
6737
  }
6740
6738
  }
6739
+ // source/core/socket/metadata.ts
6740
+ var import_reflect_metadata3 = __toESM(require_Reflect2(), 1);
6741
+ var registry = new Map;
6741
6742
  // source/framework/plugins/body-parser.plugin.ts
6742
6743
  function bodyParserPlugin() {
6743
6744
  return {
@@ -6890,8 +6891,6 @@ function decode(data) {
6890
6891
  return data;
6891
6892
  return new TextDecoder().decode(data);
6892
6893
  }
6893
- // source/core/socket/metadata.ts
6894
- var import_reflect_metadata3 = __toESM(require_Reflect2(), 1);
6895
6894
  // source/framework/decorators/routable.decorator.ts
6896
6895
  function stabilizeRoute(meta, { path: path3, method, propertyKey }) {
6897
6896
  return {
@@ -7288,7 +7287,8 @@ class Artifacts {
7288
7287
  "dto",
7289
7288
  "entity",
7290
7289
  "model",
7291
- "schema"
7290
+ "schema",
7291
+ "socket"
7292
7292
  ];
7293
7293
  static register(type) {
7294
7294
  this.types.add(type);
@@ -7311,17 +7311,6 @@ class Artifacts {
7311
7311
  if (filename)
7312
7312
  Injection.registerArtifactPath(name, filename);
7313
7313
  Injection.updateConstruct(name, mod);
7314
- const dependents = Injection.getDependents(name);
7315
- for (const dependent of dependents) {
7316
- const dependentPath = Injection.getArtifactPath(dependent);
7317
- if (dependentPath && isControllerArtifact(dependentPath)) {
7318
- Raiton.signals.dispatch("hmr:controller", {
7319
- filename: dependentPath,
7320
- timestamp: Date.now(),
7321
- version: 1
7322
- });
7323
- }
7324
- }
7325
7314
  }
7326
7315
  }
7327
7316
  }
package/docs/README.md CHANGED
@@ -1,136 +1,13 @@
1
- # Raiton — Documentation Développeur
1
+ # Documentation
2
2
 
3
- Framework backend TypeScript modulaire avec injection de dépendances, plugins, contrôleurs, middleware et hot-reloading. Optimisé pour **Bun**, compatible **Node.js** et **Deno**.
3
+ Le dossier `docs/` est séparé en deux parcours :
4
4
 
5
- ```
6
- Version: 5.9.4-beta.15 | Runtime: Bun (recommandé), Node.js, Deno | Licence: MIT
7
- ```
5
+ - [contributors/](contributors/README.md) pour la documentation dédiée aux contributeurs
6
+ - [user-guide/](user-guide/README.md) pour la documentation dédiée aux développeurs qui créent leur serveur d'API
8
7
 
9
8
  ## Navigation
10
9
 
11
10
  | Section | Description |
12
11
  |---------|-------------|
13
- | [core/](core/README.md) | Noyau : Application, Router, Middleware, DI, Plugins, Config |
14
- | [framework/](framework/README.md) | Décorateurs, Runtime, Réponses, Encryption, Plugins intégrés |
15
- | [cli/](cli/README.md) | CLI, commandes develop/build/start, HMR |
16
- | [types/](types/README.md) | Système de types et interfaces |
17
-
18
- ## Structure de la documentation
19
-
20
- ```
21
- docs/
22
- ├── README.md ← Ce fichier
23
- ├── core/ ← Module noyau
24
- │ ├── README.md ← Sommaire core/
25
- │ ├── application.md ← Classe Application
26
- │ ├── router.md ← Router, Route, RouteMatcher
27
- │ ├── middleware.md ← Pipeline middleware
28
- │ ├── controller.md ← ControllerBuilder, compilation
29
- │ ├── injection.md ← Injection de dépendances
30
- │ ├── plugin-scope.md ← Système de plugins
31
- │ ├── config.md ← Configuration
32
- │ └── builder-thread.md ← Build, thread, cycle de vie
33
- ├── framework/ ← Module framework
34
- │ ├── README.md ← Sommaire framework/
35
- │ ├── runtime.md ← Adaptateurs Bun/Node/Deno
36
- │ ├── responses.md ← Réponses et exceptions
37
- │ ├── encryption.md ← Hachage et chiffrement
38
- │ ├── env.md ← Variables d'environnement
39
- │ ├── base-classes.md ← DTO, ViewModel, Service, Repository
40
- │ ├── decorators/ ← Décorateurs
41
- │ │ ├── README.md ← Sommaire décorateurs
42
- │ │ ├── controllable.md ← @Controllable, @Get, @Post...
43
- │ │ ├── parametrable.md ← @Param, @Query, @Body...
44
- │ │ ├── injection.md ← @Injectable, @Inject
45
- │ │ ├── middleware.md ← @Middleware
46
- │ │ ├── socket.md ← @Socket, événements socket
47
- │ │ └── openapi.md ← Décorateurs OpenAPI
48
- │ └── plugins/ ← Plugins intégrés
49
- │ ├── README.md ← Sommaire plugins
50
- │ ├── body-parser.md ← Body parser
51
- │ ├── openapi.md ← Plugin OpenAPI
52
- │ └── security.md ← CORS, headers, rate-limit...
53
- ├── cli/ ← CLI
54
- │ ├── README.md ← Sommaire CLI
55
- │ ├── commands.md ← Commandes disponibles
56
- │ └── hmr.md ← Hot Module Replacement
57
- └── types/ ← Types
58
- └── README.md ← 29 fichiers de types
59
- ```
60
-
61
- ## Table des matières
62
-
63
- - [Démarrage rapide](#démarrage-rapide)
64
- - [Points d'entrée (package.json exports)](#points-dentrée-packagejson-exports)
65
- - [Conventions de commits](#conventions-de-commits)
66
-
67
- ## Démarrage rapide
68
-
69
- ```bash
70
- # Installation
71
- bun add raiton reflect-metadata
72
- ```
73
-
74
- ```typescript
75
- // source/controllers/hello.controller.ts
76
- import { Controllable, Get, Param } from "raiton/framework"
77
-
78
- @Controllable("/hello")
79
- export class HelloController {
80
- @Get("/")
81
- index() {
82
- return { message: "Bonjour de Raiton !" }
83
- }
84
-
85
- @Get("/:name")
86
- greet(@Param("name") name?: string) {
87
- return { message: `Bonjour, ${name} !` }
88
- }
89
- }
90
-
91
- // source/main.ts (bootstrapper)
92
- import "reflect-metadata"
93
- import { ThreadInterface } from "raiton/types"
94
- import { Application } from "raiton/core"
95
- import { HelloController } from "./controllers/hello.controller"
96
-
97
- export default async function (thread: ThreadInterface) {
98
- const app = new Application({ port: 3000, prefix: "/api" })
99
- app.register({ setup: (s) => s.get("/hello", (c) => c.reply.send("Hello")))
100
- return await thread.setup({ application: app }).run()
101
- }
102
- ```
103
-
104
- ```bash
105
- # Lancer en développement
106
- bun raiton dev
107
- ```
108
-
109
- ## Points d'entrée (package.json exports)
110
-
111
- | Import | Chemin |
112
- |--------|--------|
113
- | `raiton` ou `raiton/core` | `source/core/index.ts` |
114
- | `raiton/core/*` | `source/core/*.ts` |
115
- | `raiton/framework` | `source/framework/index.ts` |
116
- | `raiton/framework/*` | `source/framework/*.ts` |
117
- | `raiton/types` | `source/types/index.ts` |
118
- | `raiton/types/*` | `source/types/*.ts` |
119
- | `raiton/commands/*` | `source/commands/*.ts` |
120
-
121
- ## Conventions
122
-
123
- ### Fonctionnalités
124
- Il faut toujours prioriser sur l'existant des fonctionnalités existantes avant de créer de nouvelles fonctionnalités.
125
-
126
- ### Commits
127
-
128
- | Préfixe | Domaine |
129
- |---------|---------|
130
- | `core:` | Noyau (Application, Router, DI, etc.) |
131
- | `framework:` | Décorateurs, runtime, plugins |
132
- | `cli:` | Ligne de commande |
133
- | `docs:` | Documentation |
134
- | `types:` | Définitions de types |
135
- | `fix:` | Correction de bug |
136
- | `chore:` | Maintenance |
12
+ | [contributors/](contributors/README.md) | Architecture interne, noyau, runtime, décorateurs, plugins, CLI, types |
13
+ | [user-guide/](user-guide/README.md) | Démarrage, architecture d’un projet, API, injection, workflow |
@@ -0,0 +1,103 @@
1
+ # Raiton — Documentation Contributeur
2
+
3
+ Documentation orientée contribution au framework: architecture interne, noyau, runtime, décorateurs, plugins, CLI et types.
4
+
5
+ Pour l’usage applicatif, voir [../user-guide/README.md](../user-guide/README.md).
6
+
7
+ ```
8
+ Version: 5.9.4-beta.15 | Runtime: Bun (recommandé), Node.js, Deno | Licence: MIT
9
+ ```
10
+
11
+ ## Navigation
12
+
13
+ | Section | Description |
14
+ |---------|-------------|
15
+ | [core/](core/README.md) | Noyau : Application, Router, Middleware, DI, Plugins, Config |
16
+ | [framework/](framework/README.md) | Décorateurs, Runtime, Réponses, Encryption, Plugins intégrés |
17
+ | [cli/](cli/README.md) | CLI, commandes develop/build/start, HMR |
18
+ | [types/](types/README.md) | Système de types et interfaces |
19
+
20
+ ## Structure de la documentation
21
+
22
+ ```
23
+ docs/
24
+ ├── README.md ← Ce fichier
25
+ ├── core/ ← Module noyau
26
+ │ ├── README.md ← Sommaire core/
27
+ │ ├── application.md ← Classe Application
28
+ │ ├── router.md ← Router, Route, RouteMatcher
29
+ │ ├── middleware.md ← Pipeline middleware
30
+ │ ├── controller.md ← ControllerBuilder, compilation
31
+ │ ├── injection.md ← Injection de dépendances
32
+ │ ├── plugin-scope.md ← Système de plugins
33
+ │ ├── config.md ← Configuration
34
+ │ └── builder-thread.md ← Build, thread, cycle de vie
35
+ ├── framework/ ← Module framework
36
+ │ ├── README.md ← Sommaire framework/
37
+ │ ├── runtime.md ← Adaptateurs Bun/Node/Deno
38
+ │ ├── responses.md ← Réponses et exceptions
39
+ │ ├── encryption.md ← Hachage et chiffrement
40
+ │ ├── env.md ← Variables d'environnement
41
+ │ ├── base-classes.md ← DTO, ViewModel, Service, Repository
42
+ │ ├── decorators/ ← Décorateurs
43
+ │ │ ├── README.md ← Sommaire décorateurs
44
+ │ │ ├── controllable.md ← @Controllable, @Get, @Post...
45
+ │ │ ├── parametrable.md ← @Param, @Query, @Body...
46
+ │ │ ├── injection.md ← @Injectable, @Inject
47
+ │ │ ├── middleware.md ← @Middleware
48
+ │ │ ├── socket.md ← @Socket, événements socket
49
+ │ │ └── openapi.md ← Décorateurs OpenAPI
50
+ │ └── plugins/ ← Plugins intégrés
51
+ │ ├── README.md ← Sommaire plugins
52
+ │ ├── body-parser.md ← Body parser
53
+ │ ├── openapi.md ← Plugin OpenAPI
54
+ │ └── security.md ← CORS, headers, rate-limit...
55
+ ├── cli/ ← CLI
56
+ │ ├── README.md ← Sommaire CLI
57
+ │ ├── commands.md ← Commandes disponibles
58
+ │ └── hmr.md ← Hot Module Replacement
59
+ └── types/ ← Types
60
+ └── README.md ← 29 fichiers de types
61
+ ```
62
+
63
+ ## Table des matières
64
+
65
+ - [Structure de la documentation](#structure-de-la-documentation)
66
+ - [Points d'entrée (package.json exports)](#points-dentrée-packagejson-exports)
67
+ - [Conventions de commits](#conventions-de-commits)
68
+
69
+ ## Points d'entrée (package.json exports)
70
+
71
+ | Import | Chemin |
72
+ |--------|--------|
73
+ | `raiton` ou `raiton/core` | `source/core/index.ts` |
74
+ | `raiton/core/*` | `source/core/*.ts` |
75
+ | `raiton/framework` | `source/framework/index.ts` |
76
+ | `raiton/framework/*` | `source/framework/*.ts` |
77
+ | `raiton/types` | `source/types/index.ts` |
78
+ | `raiton/types/*` | `source/types/*.ts` |
79
+ | `raiton/commands/*` | `source/commands/*.ts` |
80
+
81
+ ### Fonctionnalités
82
+ Il faut toujours prioriser sur l'existant des fonctionnalités existantes avant de créer de nouvelles fonctionnalités.
83
+
84
+ ### Commits
85
+ Les commits doivent être des commits logiques séparés par domaine, par fonctionnalité ou par objectif dans l'ordre de modifications des fichiers.
86
+ Utiliser les préfixes suivants :
87
+
88
+ | Préfixe | Usage |
89
+ |------------------|-------|
90
+ | `feat` | Nouvelle fonctionnalité |
91
+ | `fix` | Correction de bug |
92
+ | `breaking change`| Changement cassant (rétro-incompatible) |
93
+ | `release` | Préparation de release |
94
+ | `upgrade` | Mise à jour de dépendances |
95
+ | `update` | Mise à jour de code existant (sans ajout de fonctionnalité) |
96
+ | `add` | Ajout de code mineur (logs, helpers, fichiers de config) |
97
+ | `refactor` | Refactoring sans changement de comportement |
98
+ | `chore` | Tâches internes (build, config, CI, workspace) |
99
+ | `docs` | Documentation uniquement |
100
+ | `remove` | Suppression de code ou de fichiers |
101
+ | `deprecate` | Marquage d'une fonctionnalité comme dépréciée |
102
+
103
+ Executer ```bun run version``` pour mettre à jour la version de l'application automatiquement
@@ -3,7 +3,7 @@
3
3
  **Fichiers :** `source/bin/`, `source/commands/`
4
4
  **Import CLI :** `bun raiton <commande>`
5
5
 
6
- > **Navigation :** [← docs/](../README.md) | [↑ Index](../README.md) | [commands.md →](commands.md)
6
+ > **Navigation :** [← docs contributeur](../README.md) | [↑ Index](../README.md) | [commands.md →](commands.md)
7
7
 
8
8
  ## Table des matières
9
9
 
@@ -18,15 +18,10 @@ Watcher (fs.watch, recursive)
18
18
  v
19
19
  builder.parse(filename)
20
20
  │
21
- ├── isControllerArtifact(filename)
22
- │ → dispatch 'hmr:controller'
23
- │ → ControllerBuilder.build({filename, version, timestamp})
24
- │ → Réimporte et recompile le contrôleur
25
- │ → Remplace la route dans le router
26
- │
27
- └── Artifacts.is(filename)
28
- → Artifacts.reload(module, filename)
29
- → Met à jour le registre des artifacts
21
+ └── dispatch 'hmr:artifact'
22
+ ├── si contrôleur / socket → ControllerBuilder.build({filename, version, timestamp})
23
+ └── sinon → Artifacts.reload(module, filename)
24
+ → Met à jour le registre des artifacts
30
25
  ```
31
26
 
32
27
  ## Watcher
@@ -50,13 +45,19 @@ Le watcher utilise `fs.watch()` de Node.js avec l'option `recursive: true`.
50
45
  ```typescript
51
46
  // Réception du signal (dans builder.prepare())
52
47
  if (this.options.hmr && this.options.serve) {
53
- Raiton.signals.listen('hmr:controller', async ({filename, version, timestamp}) => {
54
- await ControllerBuilder.build({filename, version, timestamp})
48
+ Raiton.signals.listen('hmr:artifact', async ({filename, version, timestamp}) => {
49
+ const imported = await import(`${filename}?v=${version || 1}&t=${timestamp || Date.now()}`)
50
+ if (isControllerArtifact(filename) || isSocketArtifact(filename)) {
51
+ await ControllerBuilder.build({filename, version, timestamp})
52
+ return
53
+ }
54
+
55
+ Artifacts.reload(imported, filename)
55
56
  })
56
57
  }
57
58
  ```
58
59
 
59
- Le signal `hmr:controller` est dispatché via `Raiton.signals` (EventBus de `@protorians/events-bus`).
60
+ Le signal `hmr:artifact` est le seul point d'entrée du HMR côté runtime. Le type de fichier est résolu localement.
60
61
 
61
62
  ## Rechargement avec cache busting
62
63
 
@@ -71,15 +72,9 @@ protected async parse(filename: string) {
71
72
  type,
72
73
  }
73
74
 
74
- if (isControllerArtifact(filename)) {
75
- Raiton.signals.dispatch('hmr:controller', payload)
75
+ if (Artifacts.is(filename) || isControllerArtifact(filename) || isSocketArtifact(filename)) {
76
+ Raiton.signals.dispatch('hmr:artifact', payload)
76
77
  }
77
-
78
- if (Artifacts.is(filename))
79
- Artifacts.reload(
80
- await import(`${filename}?v=${payload.version}&t=${payload.timestamp}`),
81
- filename
82
- )
83
78
  }
84
79
  ```
85
80
 
@@ -89,8 +84,9 @@ protected async parse(filename: string) {
89
84
 
90
85
  | Type de fichier | Comportement |
91
86
  |----------------|-------------|
92
- | `*.controller.ts` | Recompilation du contrôleur, remplacement de ses routes |
93
- | Artifacts connus (service, socket) | Rechargement du module dans le registre |
87
+ | `*.controller.ts` / `*.controller.js` | Recompilation du contrôleur via `ControllerBuilder.build()` |
88
+ | `*.socket.ts` / `*.socket.js` | Recompilation du socket via `ControllerBuilder.build()` |
89
+ | Tous les artifacts listés dans `Artifacts.defaultTypes` | Rechargement du module dans le registre |
94
90
  | Autres fichiers | Ignorés (ne déclenchent pas de rechargement) |
95
91
 
96
92
  ## Exemple
@@ -111,7 +107,8 @@ $ echo " @Get('/new') newRoute() { return 'ajouté à chaud' }" >> source/contr
111
107
 
112
108
  ## Limitations
113
109
 
114
- - Le HMR ne recharge que les **contrôleurs** et les **artifacts enregistrés**
110
+ - Le HMR ne passe que par `hmr:artifact`
111
+ - Les contrôleurs et sockets sont rechargés via le même signal, mais traités selon leur suffixe
115
112
  - Les modifications de **configuration** (`raiton.config.json`) nécessitent un redémarrage
116
113
  - Les modifications de **middlewares globaux** (`app.use()`) nécessitent un redémarrage
117
114
  - Le HMR dépend de `fs.watch` — peut ne pas fonctionner sur certains systèmes de fichiers distants (NFS, Docker volumes sur macOS)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Le noyau de Raiton gère le cycle de vie de l'application, le routage, le middleware, l'injection de dépendances, les plugins et la configuration.
4
4
 
5
- > **Navigation :** [← docs/](../README.md) | [↑ Index](../README.md) | [application.md →](application.md)
5
+ > **Navigation :** [← docs contributeur](../README.md) | [↑ Index](../README.md) | [application.md →](application.md)
6
6
 
7
7
  ## Table des matières
8
8
 
@@ -26,11 +26,11 @@ class RaitonBuilder {
26
26
 
27
27
  Initialise les chemins et active le HMR si demandé :
28
28
 
29
- ```typescript
29
+ ```
30
30
  async prepare(): Promise<this> {
31
31
  1. initialize() → résout source, out, bootstrapper
32
32
  2. Si options.hmr && options.serve:
33
- - Écoute le signal 'hmr:controller'
33
+ - Écoute le signal 'hmr:artifact'
34
34
  - Active le watcher sur le dossier source
35
35
  }
36
36
  ```
@@ -78,11 +78,8 @@ protected watching(): this {
78
78
  }
79
79
 
80
80
  protected async parse(filename: string) {
81
- if (isControllerArtifact(filename)) {
82
- Raiton.signals.dispatch('hmr:controller', {filename, ...})
83
- }
84
- if (Artifacts.is(filename)) {
85
- Artifacts.reload(await import(`${filename}?v=${version}&t=${timestamp}`), filename)
81
+ if (Artifacts.is(filename) || isControllerArtifact(filename) || isSocketArtifact(filename)) {
82
+ Raiton.signals.dispatch('hmr:artifact', {filename, ...})
86
83
  }
87
84
  }
88
85
  ```
@@ -62,7 +62,7 @@ await ControllerBuilder.scan("./source")
62
62
  Recompile un seul contrôleur (utilisé par le HMR lors d'un changement de fichier) :
63
63
 
64
64
  ```typescript
65
- // Appelé par le watcher HMR via le signal 'hmr:controller'
65
+ // Appelé par le watcher HMR via le signal 'hmr:artifact'
66
66
  await ControllerBuilder.build({
67
67
  filename: "./source/controllers/user.controller.ts",
68
68
  version: 2,
@@ -0,0 +1,67 @@
1
+ # Module Framework
2
+
3
+ Le dossier `source/framework/` regroupe les briques publiques du framework: décorateurs, runtime, réponses, exceptions, plugins, utilitaires et classes de base.
4
+
5
+ > **Navigation :** [← docs contributeur](../README.md) | [↑ Index](../README.md) | [runtime.md →](runtime.md)
6
+
7
+ ## Menu
8
+
9
+ | Chapitre | Description |
10
+ |---|---|
11
+ | [runtime.md](runtime.md) | Adaptateurs Bun et Node, fabrique `Runtime` |
12
+ | [responses.md](responses.md) | Réponses HTTP, exceptions, helpers de rendu |
13
+ | [encryption.md](encryption.md) | Hash, dérivation, mots de passe |
14
+ | [env.md](env.md) | Variables d’environnement |
15
+ | [base-classes.md](base-classes.md) | DTO, ViewModel, services, repositories, bag de paramètres |
16
+ | [decorators/](decorators/README.md) | Décorateurs du framework |
17
+ | [plugins/](plugins/README.md) | Body parser, OpenAPI, sécurité |
18
+
19
+ ## Ce que fournit ce module
20
+
21
+ - un système de décorateurs basé sur `reflect-metadata`
22
+ - une abstraction runtime pour Bun et Node
23
+ - des réponses et exceptions prêtes à l’emploi
24
+ - des helpers pour la sécurité, l’OpenAPI et les requêtes
25
+ - des classes de base pour structurer une application
26
+
27
+ ## Vue d’ensemble des exports
28
+
29
+ ```text
30
+ framework/
31
+ ├── index.ts
32
+ ├── controllers.ts
33
+ ├── services.ts
34
+ ├── repositories.ts
35
+ ├── view-model.ts
36
+ ├── data-transfer-object.ts
37
+ ├── encryption.ts
38
+ ├── parameter-bag.ts
39
+ ├── artifacts.ts
40
+ ├── env.ts
41
+ ├── decorators/
42
+ ├── plugins/
43
+ ├── runtime/
44
+ ├── enums/
45
+ ├── constants/
46
+ ├── exceptions/
47
+ ├── responses/
48
+ └── utilities/
49
+ ```
50
+
51
+ ## Parcours recommandé
52
+
53
+ 1. Commencer par [runtime.md](runtime.md) pour comprendre l’exécution HTTP.
54
+ 2. Lire [responses.md](responses.md) pour voir comment les réponses et exceptions sont rendues.
55
+ 3. Lire [decorators/README.md](decorators/README.md) pour la partie la plus visible côté application.
56
+ 4. Lire [plugins/README.md](plugins/README.md) pour le body parser, OpenAPI et la sécurité.
57
+ 5. Lire [base-classes.md](base-classes.md) pour les objets de base.
58
+
59
+ ## Points d’attention
60
+
61
+ - Le module repose fortement sur les métadonnées TypeScript.
62
+ - Le runtime Bun est le plus complet.
63
+ - Certaines parties sont plus orientées architecture framework que usage applicatif direct.
64
+
65
+ ---
66
+
67
+ [← docs contributeur](../README.md) | [↑ Index](../README.md) | [runtime.md →](runtime.md)
@@ -179,13 +179,40 @@ Registre des types d'artifacts avec support HMR.
179
179
  import { Artifacts } from "raiton/framework"
180
180
 
181
181
  // Types par défaut
182
- Artifacts.defaultTypes // ["controller", "socket", "service"]
182
+ Artifacts.defaultTypes // [
183
+ // "service",
184
+ // "provider",
185
+ // "type",
186
+ // "interface",
187
+ // "repository",
188
+ // "database",
189
+ // "db",
190
+ // "util",
191
+ // "utility",
192
+ // "source",
193
+ // "controller",
194
+ // "socket",
195
+ // "middleware",
196
+ // "hook",
197
+ // "event",
198
+ // "listener",
199
+ // "validator",
200
+ // "strategy",
201
+ // "strategy-provider",
202
+ // "strategy-type",
203
+ // "use-case",
204
+ // "dto",
205
+ // "entity",
206
+ // "model",
207
+ // "schema",
208
+ // ]
183
209
 
184
210
  // Enregistrer des types supplémentaires
185
211
  Artifacts.registerMany("command", "event")
186
212
 
187
213
  // Vérifier si un fichier est un artifact
188
- Artifacts.is("user.controller.ts") // true (contient "controller")
214
+ Artifacts.is("user.controller.ts") // true
215
+ Artifacts.is("user.controller.js") // true
189
216
  Artifacts.is("user.service.ts") // true
190
217
  Artifacts.is("README.md") // false
191
218
 
@@ -204,6 +231,7 @@ import {
204
231
  } from "raiton/framework"
205
232
 
206
233
  isControllerArtifact("user.controller.ts") // true
234
+ isControllerArtifact("user.controller.js") // true
207
235
  isSocketArtifact("chat.socket.ts") // true
208
236
  isServiceArtifact("auth.service.ts") // true
209
237
  isArtifact("user.controller.ts") // true (n'importe quel type)
@@ -141,11 +141,39 @@ interface SocketMetaInterface {
141
141
  }
142
142
  ```
143
143
 
144
+ Utilisez `getSocketMetadata(target)` de `source/core/socket/metadata.ts` pour lire les métadonnées d'une classe socket.
145
+
144
146
  ## Notes
145
147
 
146
- - La fonctionnalité socket est en développement — le runtime sous-jacent est à implémenter
147
- - Les décorateurs stockent les métadonnées mais le traitement effectif dépendra de l'adaptateur socket
148
- - Utilisez `getSocketMetadata(target)` de `source/core/socket/metadata.ts` pour lire les métadonnées
148
+ - Le runtime socket est implémenté pour l'adaptateur **Bun** (`source/framework/runtime/bun/server.ts`). Les requests avec l'en-tête `Upgrade: websocket` sont routées vers le namespace socket correspondant ; les autres restent traitées par le router HTTP.
149
+ - Le namespace est matché sur le `pathname` de la request. Le préfixe d'application (`prefix`, ex. `/api`) est automatiquement pris en compte : `ws://host/notifications` et `ws://host/api/notifications` atteignent tous deux un socket enregistré sur `/notifications`.
150
+ - Une **instance transiente** de la classe socket est créée par connexion via le conteneur d'injection : chaque client possède son propre état. La même instance reçoit `connect`, `message` et `disconnect`.
151
+ - Les artifacts `.socket.ts` sont scannés automatiquement au boot (comme les contrôleurs) et rechargés en HMR.
152
+
153
+ ### Protocole de messages
154
+
155
+ Le client envoie des trames JSON `{ event, data }` :
156
+
157
+ ```typescript
158
+ ws.send(JSON.stringify({
159
+ event: 'mon-evenement',
160
+ data: { cle: 'valeur' }
161
+ }))
162
+ ```
163
+
164
+ - `event` : nom de l'événement (`@OnSocketEvent(name)`) ou du message (`@OnSocketMessage(name)`).
165
+ - `data` : payload passé au handler.
166
+ - Sans champ `event`, la trame est routée vers un handler de type `message` (payload brut).
167
+
168
+ Si un handler **retourne une valeur** (par ex. `RaitonResponses(...)`), le runtime l'envoie automatiquement au client sous forme de trame JSON.
169
+
170
+ | Cas | Comportement |
171
+ |-----|--------------|
172
+ | Événement trouvé | Appel du handler, réponse éventuelle renvoyée au client |
173
+ | Événement inconnu | Réponse `{ statusCode: 404, message: "Socket event \"...\" not found", data: null }` |
174
+ | Erreur dans le handler | Réponse `{ statusCode: 500, message: "Internal server error", data: null }` |
175
+
176
+ ### Métadonnées socket
149
177
 
150
178
  ---
151
179