raiton 6.0.0-beta.1 → 6.0.2-beta.3
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/README.md +13 -9
- package/build/bin/index.mjs +4 -16
- package/docs/README.md +6 -136
- package/docs/contributors/README.md +103 -0
- package/docs/{cli → contributors/cli}/README.md +1 -1
- package/docs/{cli → contributors/cli}/hmr.md +20 -23
- package/docs/{core → contributors/core}/README.md +1 -1
- package/docs/{core → contributors/core}/builder-thread.md +4 -7
- package/docs/{core → contributors/core}/controller.md +1 -1
- package/docs/contributors/framework/README.md +67 -0
- package/docs/{framework → contributors/framework}/base-classes.md +30 -2
- package/docs/{types → contributors/types}/README.md +1 -1
- package/docs/user-guide/README.md +62 -0
- package/docs/user-guide/api/README.md +21 -0
- package/docs/user-guide/api/example.md +50 -0
- package/docs/user-guide/api/responses.md +58 -0
- package/docs/user-guide/api/routes.md +56 -0
- package/docs/user-guide/architecture.md +83 -0
- package/docs/user-guide/best-practices.md +36 -0
- package/docs/user-guide/body-parser.md +39 -0
- package/docs/user-guide/cli.md +51 -0
- package/docs/user-guide/config.md +47 -0
- package/docs/user-guide/decorators/README.md +33 -0
- package/docs/user-guide/decorators/api-body.md +47 -0
- package/docs/user-guide/decorators/api-operation.md +47 -0
- package/docs/user-guide/decorators/api-param.md +47 -0
- package/docs/user-guide/decorators/api-property.md +46 -0
- package/docs/user-guide/decorators/api-query.md +47 -0
- package/docs/user-guide/decorators/api-response.md +48 -0
- package/docs/user-guide/decorators/api-tags.md +47 -0
- package/docs/user-guide/decorators/controllable.md +46 -0
- package/docs/user-guide/decorators/guard.md +57 -0
- package/docs/user-guide/decorators/injection.md +55 -0
- package/docs/user-guide/decorators/middleware.md +56 -0
- package/docs/user-guide/decorators/parameters.md +57 -0
- package/docs/user-guide/decorators/route-interaction.md +47 -0
- package/docs/user-guide/decorators/routes.md +62 -0
- package/docs/user-guide/decorators/socket.md +59 -0
- package/docs/user-guide/encryption.md +40 -0
- package/docs/user-guide/env.md +39 -0
- package/docs/user-guide/getting-started.md +72 -0
- package/docs/user-guide/injection.md +80 -0
- package/docs/user-guide/middleware.md +98 -0
- package/docs/user-guide/openapi/README.md +70 -0
- package/docs/user-guide/openapi/plugin.md +72 -0
- package/docs/user-guide/plugins.md +69 -0
- package/docs/user-guide/responses.md +99 -0
- package/docs/user-guide/runtime.md +44 -0
- package/docs/user-guide/security.md +46 -0
- package/docs/user-guide/sockets.md +49 -0
- package/docs/user-guide/tutorial.md +175 -0
- package/docs/user-guide/types.md +118 -0
- package/package.json +1 -1
- package/source/commands/build.command.ts +2 -2
- package/source/core/builder.ts +14 -23
- package/source/framework/artifacts.ts +3 -12
- package/source/types/raiton.ts +2 -3
- package/docs/framework/README.md +0 -96
- /package/docs/{cli → contributors/cli}/commands.md +0 -0
- /package/docs/{core → contributors/core}/application.md +0 -0
- /package/docs/{core → contributors/core}/config.md +0 -0
- /package/docs/{core → contributors/core}/injection.md +0 -0
- /package/docs/{core → contributors/core}/middleware.md +0 -0
- /package/docs/{core → contributors/core}/plugin-scope.md +0 -0
- /package/docs/{core → contributors/core}/router.md +0 -0
- /package/docs/{framework → contributors/framework}/decorators/README.md +0 -0
- /package/docs/{framework → contributors/framework}/decorators/controllable.md +0 -0
- /package/docs/{framework → contributors/framework}/decorators/injection.md +0 -0
- /package/docs/{framework → contributors/framework}/decorators/middleware.md +0 -0
- /package/docs/{framework → contributors/framework}/decorators/openapi.md +0 -0
- /package/docs/{framework → contributors/framework}/decorators/parametrable.md +0 -0
- /package/docs/{framework → contributors/framework}/decorators/socket.md +0 -0
- /package/docs/{framework → contributors/framework}/encryption.md +0 -0
- /package/docs/{framework → contributors/framework}/env.md +0 -0
- /package/docs/{framework → contributors/framework}/plugins/README.md +0 -0
- /package/docs/{framework → contributors/framework}/plugins/body-parser.md +0 -0
- /package/docs/{framework → contributors/framework}/plugins/openapi.md +0 -0
- /package/docs/{framework → contributors/framework}/plugins/security.md +0 -0
- /package/docs/{framework → contributors/framework}/responses.md +0 -0
- /package/docs/{framework → contributors/framework}/runtime.md +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Sockets
|
|
2
|
+
|
|
3
|
+
> **Navigation :** [← openapi](openapi/README.md) | [tutorial →](tutorial.md)
|
|
4
|
+
|
|
5
|
+
Les sockets servent à créer des échanges temps réel.
|
|
6
|
+
|
|
7
|
+
## Exemple
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { Socket, OnSocketConnect, OnSocketMessage } from "raiton/framework"
|
|
11
|
+
|
|
12
|
+
@Socket("/chat")
|
|
13
|
+
export class ChatSocket {
|
|
14
|
+
@OnSocketConnect()
|
|
15
|
+
connect() {
|
|
16
|
+
return { connected: true }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@OnSocketMessage("message")
|
|
20
|
+
message(payload: any) {
|
|
21
|
+
return { ok: true, payload }
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Pourquoi utilisé
|
|
27
|
+
|
|
28
|
+
- notifications temps réel
|
|
29
|
+
- chat
|
|
30
|
+
- synchronisation instantanée
|
|
31
|
+
|
|
32
|
+
## Comment l’utiliser
|
|
33
|
+
|
|
34
|
+
- déclarez une classe socket
|
|
35
|
+
- ajoutez des handlers avec `@OnSocketConnect()` et `@OnSocketMessage()`
|
|
36
|
+
|
|
37
|
+
## Avantages
|
|
38
|
+
|
|
39
|
+
- intégration naturelle avec le runtime Bun
|
|
40
|
+
- API simple à déclarer
|
|
41
|
+
|
|
42
|
+
## Inconvénients
|
|
43
|
+
|
|
44
|
+
- support plus limité que le HTTP
|
|
45
|
+
- dépend du runtime choisi
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
[← openapi](openapi/README.md) | [tutorial →](tutorial.md)
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# Tutoriel complet
|
|
2
|
+
|
|
3
|
+
> **Navigation :** [← responses](responses.md) | [plugins →](plugins.md)
|
|
4
|
+
|
|
5
|
+
Ce tutoriel assemble les briques du guide dans un flux concret:
|
|
6
|
+
- configuration du projet
|
|
7
|
+
- bootstrap du serveur
|
|
8
|
+
- contrôleur
|
|
9
|
+
- service
|
|
10
|
+
- middleware
|
|
11
|
+
- réponse structurée
|
|
12
|
+
|
|
13
|
+
## 1. Configuration du projet
|
|
14
|
+
|
|
15
|
+
Créez un fichier `raiton.config.ts` à la racine:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
export default {
|
|
19
|
+
rootDir: "./source",
|
|
20
|
+
version: "0.10.0",
|
|
21
|
+
port: 5711,
|
|
22
|
+
pathname: "/"
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 2. Point d’entrée
|
|
27
|
+
|
|
28
|
+
Dans `source/main.ts`:
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import "reflect-metadata"
|
|
32
|
+
import { ThreadInterface } from "raiton/types"
|
|
33
|
+
import { Application } from "raiton/core"
|
|
34
|
+
import { RuntimeType } from "raiton/framework"
|
|
35
|
+
import { UsersController } from "./controllers/users.controller"
|
|
36
|
+
|
|
37
|
+
export default async (thread: ThreadInterface) => {
|
|
38
|
+
const app = new Application({
|
|
39
|
+
port: 5711,
|
|
40
|
+
prefix: "/api"
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
app.get("/users", () => ({
|
|
44
|
+
statusCode: 200,
|
|
45
|
+
error: false,
|
|
46
|
+
message: "Users retrieved",
|
|
47
|
+
data: []
|
|
48
|
+
}))
|
|
49
|
+
|
|
50
|
+
return await thread.setup({
|
|
51
|
+
application: app,
|
|
52
|
+
runtime: RuntimeType.Bun
|
|
53
|
+
}).run()
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 3. Service métier
|
|
58
|
+
|
|
59
|
+
Dans `source/services/users.service.ts`:
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { Injectable } from "raiton/framework"
|
|
63
|
+
|
|
64
|
+
@Injectable()
|
|
65
|
+
export class UsersService {
|
|
66
|
+
private readonly users = [
|
|
67
|
+
{ id: "1", name: "John Doe" },
|
|
68
|
+
{ id: "2", name: "Jane Doe" }
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
findAll() {
|
|
72
|
+
return this.users
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
findById(id: string) {
|
|
76
|
+
return this.users.find((user) => user.id === id) ?? null
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## 4. Middleware
|
|
82
|
+
|
|
83
|
+
Dans `source/middleware/auth.middleware.ts`:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
export async function authMiddleware({ context, next }) {
|
|
87
|
+
const token = context.req.headers.get("authorization")
|
|
88
|
+
|
|
89
|
+
if (!token) {
|
|
90
|
+
context.reply.status(401)
|
|
91
|
+
return context.reply.send({
|
|
92
|
+
statusCode: 401,
|
|
93
|
+
error: true,
|
|
94
|
+
message: "Unauthorized",
|
|
95
|
+
data: null
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
context.state.user = { id: "1", role: "admin" }
|
|
100
|
+
await next()
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## 5. Contrôleur
|
|
105
|
+
|
|
106
|
+
Dans `source/controllers/users.controller.ts`:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
import { Controllable, Get, Inject, Param, Middleware } from "raiton/framework"
|
|
110
|
+
import { UsersService } from "../services/users.service"
|
|
111
|
+
import { authMiddleware } from "../middleware/auth.middleware"
|
|
112
|
+
|
|
113
|
+
@Controllable("/users")
|
|
114
|
+
@Middleware(authMiddleware)
|
|
115
|
+
export class UsersController {
|
|
116
|
+
constructor(
|
|
117
|
+
@Inject(UsersService) private readonly usersService: UsersService
|
|
118
|
+
) {}
|
|
119
|
+
|
|
120
|
+
@Get("/")
|
|
121
|
+
list() {
|
|
122
|
+
return {
|
|
123
|
+
statusCode: 200,
|
|
124
|
+
error: false,
|
|
125
|
+
message: "Users retrieved",
|
|
126
|
+
data: this.usersService.findAll()
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@Get("/:id")
|
|
131
|
+
getOne(@Param("id") id: string) {
|
|
132
|
+
const user = this.usersService.findById(id)
|
|
133
|
+
|
|
134
|
+
if (!user) {
|
|
135
|
+
return {
|
|
136
|
+
statusCode: 404,
|
|
137
|
+
error: true,
|
|
138
|
+
message: "Utilisateur introuvable",
|
|
139
|
+
data: null
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
statusCode: 200,
|
|
145
|
+
error: false,
|
|
146
|
+
message: "User retrieved",
|
|
147
|
+
data: user
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## 6. Démarrer le projet
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
bun raiton dev
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## 7. Résultat attendu
|
|
160
|
+
|
|
161
|
+
- `GET /api/users` renvoie la liste des utilisateurs
|
|
162
|
+
- `GET /api/users/:id` renvoie un utilisateur ou une erreur 404
|
|
163
|
+
- les routes du contrôleur sont protégées par un middleware d’authentification
|
|
164
|
+
|
|
165
|
+
## Ce que montre ce flux
|
|
166
|
+
|
|
167
|
+
- `source/main.ts` initialise le serveur
|
|
168
|
+
- `UsersService` contient la logique métier
|
|
169
|
+
- `UsersController` expose l’API
|
|
170
|
+
- `authMiddleware` applique une règle transversale
|
|
171
|
+
- les réponses restent standardisées
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
[← responses](responses.md) | [plugins →](plugins.md)
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Types
|
|
2
|
+
|
|
3
|
+
> **Navigation :** [← sockets](sockets.md) | [tutorial →](tutorial.md)
|
|
4
|
+
|
|
5
|
+
Le package `raiton/types` regroupe les interfaces qui servent à typer le bootstrap, les contrôleurs, le contexte de requête, les middlewares et les plugins.
|
|
6
|
+
|
|
7
|
+
Cette page ne liste pas tous les types internes du framework. Elle met en avant ceux que vous utiliserez le plus souvent pour construire un serveur d’API typé.
|
|
8
|
+
|
|
9
|
+
## Pourquoi utilisé
|
|
10
|
+
|
|
11
|
+
- éviter les objets `any` dans le point d’entrée et les couches métier
|
|
12
|
+
- rendre les signatures explicites
|
|
13
|
+
- faciliter l’autocomplétion dans l’éditeur
|
|
14
|
+
- sécuriser les contrats entre `source/main.ts`, les middlewares et les plugins
|
|
15
|
+
|
|
16
|
+
## Types principaux
|
|
17
|
+
|
|
18
|
+
- `ThreadInterface` : orchestration du serveur et démarrage de l’application
|
|
19
|
+
- `ApplicationInterface` : instance applicative configurée avec `port`, `prefix` et les routes
|
|
20
|
+
- `ContextInterface` : contexte de requête disponible dans les handlers et certains middlewares
|
|
21
|
+
- `MiddlewareParametersInterface` : contrat d’entrée d’un middleware fonctionnel
|
|
22
|
+
- `PluginInterface` : forme minimale d’un plugin Raiton
|
|
23
|
+
- `RouteHandlerCallable` : signature d’un handler de route
|
|
24
|
+
|
|
25
|
+
## Exemple d’usage
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { Application } from "raiton/core"
|
|
29
|
+
import { RuntimeType } from "raiton/framework"
|
|
30
|
+
import type {
|
|
31
|
+
ThreadInterface,
|
|
32
|
+
ContextInterface,
|
|
33
|
+
MiddlewareParametersInterface,
|
|
34
|
+
PluginInterface
|
|
35
|
+
} from "raiton/types"
|
|
36
|
+
|
|
37
|
+
const loggerPlugin: PluginInterface = {
|
|
38
|
+
name: "logger",
|
|
39
|
+
setup(scope) {
|
|
40
|
+
scope.app.use(async ({ context, next }) => {
|
|
41
|
+
console.log(`${context.req.method} ${context.req.url}`)
|
|
42
|
+
await next()
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default async (thread: ThreadInterface) => {
|
|
48
|
+
const app = new Application({
|
|
49
|
+
port: 5711,
|
|
50
|
+
prefix: "/api"
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
app.register(loggerPlugin)
|
|
54
|
+
|
|
55
|
+
app.get("/health", (ctx: ContextInterface) => {
|
|
56
|
+
ctx.reply.status(200)
|
|
57
|
+
return {
|
|
58
|
+
statusCode: 200,
|
|
59
|
+
error: false,
|
|
60
|
+
message: "OK",
|
|
61
|
+
data: null
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const authMiddleware = async ({ context, next }: MiddlewareParametersInterface) => {
|
|
66
|
+
const token = context.req.headers.get("authorization")
|
|
67
|
+
|
|
68
|
+
if (!token) {
|
|
69
|
+
context.reply.status(401)
|
|
70
|
+
return context.reply.send({
|
|
71
|
+
statusCode: 401,
|
|
72
|
+
error: true,
|
|
73
|
+
message: "Unauthorized",
|
|
74
|
+
data: null
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
await next()
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
app.use(authMiddleware)
|
|
82
|
+
|
|
83
|
+
return await thread.setup({
|
|
84
|
+
application: app,
|
|
85
|
+
runtime: RuntimeType.Bun
|
|
86
|
+
}).run()
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Comment l’utiliser
|
|
91
|
+
|
|
92
|
+
- importez les types avec `import type` quand ils ne servent qu’à la compilation
|
|
93
|
+
- utilisez `ThreadInterface` dans `source/main.ts` pour typer le bootstrap
|
|
94
|
+
- utilisez `ContextInterface` dans les handlers si vous voulez typer explicitement le contexte
|
|
95
|
+
- utilisez `MiddlewareParametersInterface` pour écrire des middlewares fonctionnels
|
|
96
|
+
- utilisez `PluginInterface` pour décrire un plugin réutilisable
|
|
97
|
+
|
|
98
|
+
## Avantages
|
|
99
|
+
|
|
100
|
+
- code plus lisible
|
|
101
|
+
- moins d’ambiguïté sur les objets manipulés
|
|
102
|
+
- meilleure détection d’erreurs au moment du développement
|
|
103
|
+
- intégration naturelle avec TypeScript
|
|
104
|
+
|
|
105
|
+
## Inconvénients
|
|
106
|
+
|
|
107
|
+
- exposition de plusieurs interfaces peut sembler plus verbeuse au début
|
|
108
|
+
- certains types sont internes et ne sont utiles qu’à des cas avancés
|
|
109
|
+
- un typage explicite demande un peu plus de discipline dans les signatures
|
|
110
|
+
|
|
111
|
+
## À retenir
|
|
112
|
+
|
|
113
|
+
Si vous ne devez retenir que quelques types, partez de `ThreadInterface`, `ApplicationInterface`, `ContextInterface`, `MiddlewareParametersInterface` et `PluginInterface`.
|
|
114
|
+
Ils couvrent la plupart des points d’entrée d’une application Raiton.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
[← sockets](sockets.md) | [tutorial →](tutorial.md)
|
package/package.json
CHANGED
|
@@ -22,11 +22,11 @@ export default class BuildCommand extends RaitonCommand {
|
|
|
22
22
|
|
|
23
23
|
const builder = new RaitonBuilder(this.workdir, {
|
|
24
24
|
serve: options.develop,
|
|
25
|
-
hmr:
|
|
25
|
+
hmr: options.develop
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
await builder.prepare()
|
|
29
29
|
await builder.boot()
|
|
30
30
|
// await builder.start(async () => (options.develop || options.bootstrap) ? await builder.boot() : void (0))
|
|
31
31
|
}
|
|
32
|
-
}
|
|
32
|
+
}
|
package/source/core/builder.ts
CHANGED
|
@@ -60,21 +60,10 @@ export class RaitonBuilder implements BuilderInterface {
|
|
|
60
60
|
type
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
Logger.log(LBadge.info('HMR'), 'activated');
|
|
63
|
+
// Logger.log(LBadge.info('HMR'), 'activated');
|
|
64
64
|
|
|
65
|
-
if (isControllerArtifact(filename))
|
|
66
|
-
Raiton.signals.dispatch('hmr:
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (isSocketArtifact(filename)) {
|
|
70
|
-
Raiton.signals.dispatch('hmr:socket', payload)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (Artifacts.is(filename))
|
|
74
|
-
Artifacts.reload(
|
|
75
|
-
await import(`${filename}?v=${payload.version || 1}&t=${payload.timestamp || Date.now()}`),
|
|
76
|
-
filename
|
|
77
|
-
)
|
|
65
|
+
if (Artifacts.is(filename) || isControllerArtifact(filename) || isSocketArtifact(filename))
|
|
66
|
+
Raiton.signals.dispatch('hmr:artifact', payload)
|
|
78
67
|
|
|
79
68
|
return payload;
|
|
80
69
|
}
|
|
@@ -124,15 +113,17 @@ export class RaitonBuilder implements BuilderInterface {
|
|
|
124
113
|
|
|
125
114
|
if (this.options.hmr && this.options.serve) {
|
|
126
115
|
Raiton.signals.listen(
|
|
127
|
-
'hmr:
|
|
116
|
+
'hmr:artifact',
|
|
128
117
|
async ({filename, version, timestamp}) => {
|
|
129
|
-
await
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
118
|
+
const imported = await import(`${filename}?v=${version || 1}&t=${timestamp || Date.now()}`)
|
|
119
|
+
|
|
120
|
+
if (isControllerArtifact(filename) || isSocketArtifact(filename)) {
|
|
121
|
+
await ControllerBuilder.build({filename, version, timestamp})
|
|
122
|
+
} else if (Artifacts.is(filename)) {
|
|
123
|
+
Artifacts.reload(imported, filename)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
Logger.log(LBadge.debug('HMR'), (path.relative(this.workdir, filename)))
|
|
136
127
|
}
|
|
137
128
|
)
|
|
138
129
|
// this.parsing();
|
|
@@ -180,4 +171,4 @@ export class RaitonBuilder implements BuilderInterface {
|
|
|
180
171
|
return app;
|
|
181
172
|
}
|
|
182
173
|
|
|
183
|
-
}
|
|
174
|
+
}
|
|
@@ -2,7 +2,7 @@ import {Injection} from "../core/injection";
|
|
|
2
2
|
import {Logger} from "@protorians/logger";
|
|
3
3
|
import type {ConstructorType} from "../types";
|
|
4
4
|
import {Raiton} from "../core/raiton";
|
|
5
|
-
import {isArtifact
|
|
5
|
+
import {isArtifact} from "./utilities";
|
|
6
6
|
|
|
7
7
|
export class Artifacts {
|
|
8
8
|
|
|
@@ -31,9 +31,11 @@ export class Artifacts {
|
|
|
31
31
|
'strategy-type',
|
|
32
32
|
'use-case',
|
|
33
33
|
'dto',
|
|
34
|
+
'vm',
|
|
34
35
|
'entity',
|
|
35
36
|
'model',
|
|
36
37
|
'schema',
|
|
38
|
+
'socket',
|
|
37
39
|
]
|
|
38
40
|
|
|
39
41
|
static register(type: string) {
|
|
@@ -68,17 +70,6 @@ export class Artifacts {
|
|
|
68
70
|
if (filename) Injection.registerArtifactPath(name, filename);
|
|
69
71
|
Injection.updateConstruct(name, mod as ConstructorType)
|
|
70
72
|
|
|
71
|
-
const dependents = Injection.getDependents(name);
|
|
72
|
-
for (const dependent of dependents) {
|
|
73
|
-
const dependentPath = Injection.getArtifactPath(dependent);
|
|
74
|
-
if (dependentPath && isControllerArtifact(dependentPath)) {
|
|
75
|
-
Raiton.signals.dispatch('hmr:controller', {
|
|
76
|
-
filename: dependentPath,
|
|
77
|
-
timestamp: Date.now(),
|
|
78
|
-
version: 1
|
|
79
|
-
})
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
73
|
}
|
|
83
74
|
}
|
|
84
75
|
|
package/source/types/raiton.ts
CHANGED
|
@@ -3,6 +3,5 @@ import {BuilderHMRDeclarationInterface} from "./builder";
|
|
|
3
3
|
export interface RaitonSignalMapInterface {
|
|
4
4
|
ready?: undefined;
|
|
5
5
|
errors: any;
|
|
6
|
-
'hmr:
|
|
7
|
-
|
|
8
|
-
}
|
|
6
|
+
'hmr:artifact': BuilderHMRDeclarationInterface;
|
|
7
|
+
}
|
package/docs/framework/README.md
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# Module Framework (`source/framework/`)
|
|
2
|
-
|
|
3
|
-
Le framework fournit les décorateurs, le runtime, les plugins intégrés, les réponses, les exceptions, les enums et les classes de base.
|
|
4
|
-
|
|
5
|
-
> **Navigation :** [← docs/](../README.md) | [↑ Index](../README.md) | [runtime.md →](runtime.md)
|
|
6
|
-
|
|
7
|
-
## Table des matières
|
|
8
|
-
|
|
9
|
-
| Fichier | Description |
|
|
10
|
-
|---------|-------------|
|
|
11
|
-
| [runtime.md](runtime.md) | Adaptateurs runtime (Bun, Node.js, Deno) |
|
|
12
|
-
| [responses.md](responses.md) | Réponses HTTP et exceptions |
|
|
13
|
-
| [encryption.md](encryption.md) | Hachage et chiffrement |
|
|
14
|
-
| [env.md](env.md) | Variables d'environnement typées |
|
|
15
|
-
| [base-classes.md](base-classes.md) | DTO, ViewModel, Service, Repository |
|
|
16
|
-
| [decorators/](decorators/README.md) | Tous les décorateurs avec exemples |
|
|
17
|
-
| [plugins/](plugins/README.md) | Plugins intégrés (body-parser, OpenAPI, sécurité) |
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
framework/
|
|
21
|
-
├── index.ts → Réexporte tout le module
|
|
22
|
-
├── controllers.ts → DelegateController (base)
|
|
23
|
-
├── services.ts → DelegateService (base)
|
|
24
|
-
├── repositories.ts → DelegateRepository (base)
|
|
25
|
-
├── view-model.ts → ViewModel (base)
|
|
26
|
-
├── data-transfer-object.ts → DataTransferObject (validation)
|
|
27
|
-
├── encryption.ts → Encryption (hashing, chiffrement)
|
|
28
|
-
├── parameter-bag.ts → ParameterBag (conteneur typé)
|
|
29
|
-
├── artifacts.ts → Artifacts (registre HMR)
|
|
30
|
-
├── env.ts → env(), envGroup()
|
|
31
|
-
├── decorators/
|
|
32
|
-
│ ├── index.ts → Réexporte tous les décorateurs
|
|
33
|
-
│ ├── controllable.decorator.ts → @Controllable
|
|
34
|
-
│ ├── routable.decorator.ts → @Get, @Post, @Put, @Patch, @Delete...
|
|
35
|
-
│ ├── parametrable.decorator.ts → @Param, @Query, @Body, @Headers...
|
|
36
|
-
│ ├── injection.decorator.ts → @Injectable, @Inject
|
|
37
|
-
│ ├── middleware.decorator.ts → @Middleware
|
|
38
|
-
│ ├── socket.decorator.ts → @Socket, @OnSocket*
|
|
39
|
-
│ ├── api.decorator.ts → @ApiTags, @ApiOperation, @ApiSecurity...
|
|
40
|
-
│ ├── api-response.decorator.ts → @ApiResponse, @ApiOkResponse, @Api*Response
|
|
41
|
-
│ └── guard.decorator.ts → Guards
|
|
42
|
-
├── plugins/
|
|
43
|
-
│ ├── index.ts → Réexporte les plugins
|
|
44
|
-
│ ├── body-parser.plugin.ts → bodyParserPlugin
|
|
45
|
-
│ ├── openapi.plugin.ts → openApiPlugin
|
|
46
|
-
│ └── security/
|
|
47
|
-
│ ├── index.ts → Security (classe statique)
|
|
48
|
-
│ ├── cors.ts → CORS middleware
|
|
49
|
-
│ ├── headers.ts → Headers sécurité
|
|
50
|
-
│ ├── rate-limit.ts → Rate limiting
|
|
51
|
-
│ ├── method-guard.ts → Méthodes HTTP autorisées
|
|
52
|
-
│ └── body-limit.ts → Taille maximale du body
|
|
53
|
-
├── runtime/
|
|
54
|
-
│ ├── index.ts → Runtime (fabrique)
|
|
55
|
-
│ ├── node/ → Adaptateur Node.js (serveur, request, reply)
|
|
56
|
-
│ ├── bun/ → Adaptateur Bun
|
|
57
|
-
│ └── deno/ → Adaptateur Deno (stub)
|
|
58
|
-
├── enums/
|
|
59
|
-
│ ├── index.ts → Réexporte les enums
|
|
60
|
-
│ ├── http-method.enum.ts → HttpMethod
|
|
61
|
-
│ ├── http-status.enum.ts → HttpStatus
|
|
62
|
-
│ ├── http-parameters.enum.ts → Parametrable
|
|
63
|
-
│ ├── runtime.enum.ts → RuntimeType
|
|
64
|
-
│ ├── encrypted.enum.ts → HashAlgoEnum, CipherAlgoEnum, PasswordAlgoEnum
|
|
65
|
-
│ ├── timestamp.enum.ts → TimestampEnum
|
|
66
|
-
│ └── event.message.enum.ts → EventMessageEnum
|
|
67
|
-
├── constants/
|
|
68
|
-
│ ├── index.ts
|
|
69
|
-
│ ├── decorators.constant.ts → METADATA_KEYS
|
|
70
|
-
│ └── microservices.constant.ts → MICROSERVICE_NAME
|
|
71
|
-
├── exceptions/
|
|
72
|
-
│ ├── index.ts
|
|
73
|
-
│ ├── throwable.ts → Throwable, throwError, throwException...
|
|
74
|
-
│ └── http-exception.ts → HttpException
|
|
75
|
-
├── responses/
|
|
76
|
-
│ ├── index.ts
|
|
77
|
-
│ ├── http.ts → HttpResponse
|
|
78
|
-
│ ├── error.ts → HttpErrorResponse
|
|
79
|
-
│ ├── http-throwable.ts → ThrowableResponse
|
|
80
|
-
│ └── helpers.ts → RaitonResponses
|
|
81
|
-
└── utilities/
|
|
82
|
-
├── index.ts
|
|
83
|
-
├── artifact.util.ts → isControllerArtifact, isSocketArtifact...
|
|
84
|
-
├── callable.util.ts → retryCallable
|
|
85
|
-
├── utilities.util.ts → getType, stabilizeJson
|
|
86
|
-
├── json.util.ts → tryParseJson, JsonUtil
|
|
87
|
-
├── path.util.ts → getDirname, getFilename, getPackageRoot
|
|
88
|
-
├── cookie.util.ts → parseCookie
|
|
89
|
-
├── ip.util.ts → getRealIp
|
|
90
|
-
├── url.ts → escapeUrl
|
|
91
|
-
└── openapi.utils.ts → generateOpenApiSpec, getSchemaFromType
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
---
|
|
95
|
-
|
|
96
|
-
[← docs/](../README.md) | [↑ Index](../README.md) | [runtime.md →](runtime.md)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|