raiton 5.7.0-beta.5 → 5.9.5-beta.16

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 (46) hide show
  1. package/build/bin/index.mjs +92 -6
  2. package/docs/README.md +131 -0
  3. package/docs/cli/README.md +81 -0
  4. package/docs/cli/commands.md +167 -0
  5. package/docs/cli/hmr.md +121 -0
  6. package/docs/core/README.md +67 -0
  7. package/docs/core/application.md +149 -0
  8. package/docs/core/builder-thread.md +231 -0
  9. package/docs/core/config.md +124 -0
  10. package/docs/core/controller.md +120 -0
  11. package/docs/core/injection.md +226 -0
  12. package/docs/core/middleware.md +172 -0
  13. package/docs/core/plugin-scope.md +171 -0
  14. package/docs/core/router.md +122 -0
  15. package/docs/framework/README.md +96 -0
  16. package/docs/framework/base-classes.md +214 -0
  17. package/docs/framework/decorators/README.md +60 -0
  18. package/docs/framework/decorators/controllable.md +151 -0
  19. package/docs/framework/decorators/injection.md +186 -0
  20. package/docs/framework/decorators/middleware.md +167 -0
  21. package/docs/framework/decorators/openapi.md +254 -0
  22. package/docs/framework/decorators/parametrable.md +248 -0
  23. package/docs/framework/decorators/socket.md +152 -0
  24. package/docs/framework/encryption.md +183 -0
  25. package/docs/framework/env.md +88 -0
  26. package/docs/framework/plugins/README.md +50 -0
  27. package/docs/framework/plugins/body-parser.md +138 -0
  28. package/docs/framework/plugins/openapi.md +217 -0
  29. package/docs/framework/plugins/security.md +159 -0
  30. package/docs/framework/responses.md +180 -0
  31. package/docs/framework/runtime.md +138 -0
  32. package/docs/types/README.md +206 -0
  33. package/package.json +1 -1
  34. package/scripts/update-version.ts +1 -0
  35. package/source/core/application.ts +30 -5
  36. package/source/core/artifacts/artifact.ts +1 -1
  37. package/source/core/router/handler.ts +5 -9
  38. package/source/core/router/handler.utils.ts +1 -2
  39. package/source/framework/constants/decorators.constant.ts +2 -0
  40. package/source/framework/decorators/index.ts +2 -1
  41. package/source/framework/decorators/route-interaction.decorator.ts +188 -0
  42. package/source/framework/decorators/socket.decorator.ts +4 -4
  43. package/source/framework/exceptions/http-exception.ts +17 -0
  44. package/source/types/router.ts +5 -0
  45. package/source/types/thread.ts +4 -1
  46. package/examples/user-controller.example.ts +0 -53
@@ -0,0 +1,206 @@
1
+ # Système de Types
2
+
3
+ **Dossier :** `source/types/`
4
+ **Import :** `import { ... } from "raiton/types"` ou `import type { ... } from "raiton/types"`
5
+
6
+ > **Navigation :** [← docs/](../README.md) | [↑ Index](../README.md)
7
+
8
+ ## Table des matières
9
+
10
+ - [Liste complète des fichiers de types](#liste-complète)
11
+ - [Interfaces clés](#interfaces-clés)
12
+ - [ApplicationConfigInterface](#applicationconfiginterface)
13
+ - [ThreadInterface](#threadinterface)
14
+ - [ContextInterface](#contextinterface)
15
+ - [MiddlewareParametersInterface](#middlewareparametersinterface)
16
+ - [ContainerDefinitionInterface](#containerdefinitioninterface)
17
+ - [PluginInterface](#plugininterface)
18
+ - [ControllerMetaInterface](#controllermetainterface)
19
+ - [ConfigurableInterface](#configurableinterface)
20
+ - [Export map](#export-map)
21
+
22
+ 29 fichiers de types dans `source/types/`, tous réexportés via `source/types/index.ts`.
23
+
24
+ ## Liste complète
25
+
26
+ | Fichier | Interface(s) principale(s) |
27
+ |---------|---------------------------|
28
+ | `application.ts` | `ApplicationInterface`, `ApplicationConfigInterface` |
29
+ | `artifact.ts` | Types d'artifacts |
30
+ | `builder.ts` | `BuilderInterface`, `BuilderConfigInterface` |
31
+ | `config.ts` | `ConfigurableInterface` |
32
+ | `contruct.ts` | `ConstructorType<T>` |
33
+ | `controller.ts` | `ControllerMetaInterface`, `RouteMetaInterface`, `RouteDecoratorCallable` |
34
+ | `core.ts` | `ContextInterface`, `RaitonCoreInterface` |
35
+ | `directory.ts` | Types de répertoires |
36
+ | `encryption.ts` | `EncryptionResultType`, `DerivationOptionsInterface`, `ScryptOptionsInterface` |
37
+ | `generic.ts` | Types génériques |
38
+ | `guard.ts` | Types de guards |
39
+ | `http-responses.ts` | Types de réponses HTTP |
40
+ | `injection.ts` | `ContainerDefinitionInterface` |
41
+ | `lifecycle.ts` | Types de cycle de vie |
42
+ | `middleware.ts` | `MiddlewareType`, `MiddlewareCallable`, `MiddlewareParametersInterface` |
43
+ | `parseable.ts` | Types de parsing |
44
+ | `plugin.ts` | `PluginInterface` |
45
+ | `raiton.ts` | Types statiques |
46
+ | `responses.ts` | Types de réponses |
47
+ | `router.ts` | Types de routage |
48
+ | `runtime.ts` | `RuntimeAdapterInterface`, `RuntimeServerInterface`, `RuntimeHandlerCallable` |
49
+ | `scheme.ts` | Types de schémas |
50
+ | `server.ts` | Types serveur |
51
+ | `socket.ts` | `SocketEventType` |
52
+ | `thread.ts` | `ThreadInterface`, `ThreadOptionsInterface`, `ThreadSetupOptionsInterface` |
53
+ | `utilities.ts` | Types utilitaires |
54
+ | `values.ts` | Types de valeurs |
55
+ | *(autres fichiers)* | |
56
+
57
+ ## Interfaces clés
58
+
59
+ ### `ApplicationConfigInterface`
60
+
61
+ ```typescript
62
+ interface ApplicationConfigInterface {
63
+ port?: number
64
+ hostname?: string
65
+ protocole?: string
66
+ pathname?: string
67
+ prefix?: string
68
+ develop?: boolean
69
+ verbose?: boolean
70
+ workdir?: string
71
+ }
72
+ ```
73
+
74
+ ### `ThreadInterface`
75
+
76
+ ```typescript
77
+ interface ThreadInterface {
78
+ application: ApplicationInterface | null
79
+ runtime: RuntimeAdapterInterface | null
80
+ runtimeServer: RuntimeServerInterface | null
81
+ readonly appDir: string
82
+ readonly builder: BuilderInterface
83
+
84
+ setup(options: ThreadSetupOptionsInterface): this
85
+ run(): Promise<this>
86
+ stop(): Promise<void>
87
+ restart(): void
88
+ sleep(ms: number): Promise<unknown>
89
+ wait(condition: ThreadWaitCallable): Promise<void>
90
+ }
91
+ ```
92
+
93
+ ### `ContextInterface`
94
+
95
+ ```typescript
96
+ interface ContextInterface {
97
+ req: any
98
+ reply: any
99
+ state: Record<string, any>
100
+ params?: Record<string, string>
101
+ send?: (data: any) => void
102
+ }
103
+ ```
104
+
105
+ ### `MiddlewareParametersInterface`
106
+
107
+ ```typescript
108
+ interface MiddlewareParametersInterface {
109
+ context: RequestContext
110
+ next: () => Promise<any>
111
+ }
112
+ ```
113
+
114
+ ### `ContainerDefinitionInterface`
115
+
116
+ ```typescript
117
+ interface ContainerDefinitionInterface {
118
+ name: string
119
+ construct: ConstructorType
120
+ lifetime: LifetimeEnum
121
+ scope?: Symbol
122
+ }
123
+ ```
124
+
125
+ ### `PluginInterface`
126
+
127
+ ```typescript
128
+ interface PluginInterface {
129
+ name: string
130
+ setup: (scope: PluginScope) => void
131
+ }
132
+ ```
133
+
134
+ ### `ControllerMetaInterface`
135
+
136
+ ```typescript
137
+ interface ControllerMetaInterface {
138
+ prefix: string
139
+ routes: RouteMetaInterface[]
140
+ middlewares: Record<string, any>
141
+ }
142
+ ```
143
+
144
+ ### `RouteMetaInterface`
145
+
146
+ ```typescript
147
+ interface RouteMetaInterface {
148
+ method: HttpMethod
149
+ path: string
150
+ propertyKey: string
151
+ }
152
+ ```
153
+
154
+ ### `ConstructorType`
155
+
156
+ ```typescript
157
+ type ConstructorType<T = any> = new (...args: any[]) => T
158
+ ```
159
+
160
+ ### `ConfigurableInterface`
161
+
162
+ ```typescript
163
+ interface ConfigurableInterface {
164
+ rootDir?: string
165
+ version?: string
166
+ port?: number
167
+ hostname?: string
168
+ protocole?: string
169
+ pathname?: string
170
+ artifacts?: { types: string[] }
171
+ }
172
+ ```
173
+
174
+ ## Export map
175
+
176
+ ```typescript
177
+ // source/types/index.ts
178
+ export type * from './config'
179
+ export type * from './builder'
180
+ export type * from './thread'
181
+ export type * from './guard'
182
+ export type * from './contruct'
183
+ export type * from './directory'
184
+ export type * from './encryption'
185
+ export type * from './generic'
186
+ export type * from './parseable'
187
+ export type * from './values'
188
+ export type * from './utilities'
189
+ export type * from './artifact'
190
+ export type * from './middleware'
191
+ export type * from './core'
192
+ export type * from './plugin'
193
+ export type * from './runtime'
194
+ export type * from './router'
195
+ export type * from './controller'
196
+ export type * from './socket'
197
+ export type * from './injection'
198
+ export type * from './responses'
199
+ export type * from './server'
200
+ export type * from './raiton'
201
+ export type * from './lifecycle'
202
+ ```
203
+
204
+ ---
205
+
206
+ [← docs/](../README.md) | [↑ Index](../README.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "raiton",
3
- "version": "5.7.0-beta.5",
3
+ "version": "5.9.5-beta.16",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Modular TypeScript Backend Framework with Dependency Injection, Plugins, Controllers, Middleware and Hot Reloading.",
@@ -49,6 +49,7 @@ function determineIncrement(commits: string[]) {
49
49
  increment = "minor";
50
50
  } else if (
51
51
  !increment &&
52
+ commit.startsWith("refactor") ||
52
53
  commit.startsWith("fix") ||
53
54
  commit.startsWith("remove")
54
55
  ) {
@@ -2,7 +2,7 @@ import {Security, bodyParserPlugin} from "../framework/plugins";
2
2
  import {PluginScope} from './plugins/scope'
3
3
  import {RequestContext} from './context'
4
4
  import {ApplicationConfigInterface, ApplicationInterface} from "../types/application";
5
- import {HttpMethod} from "../framework";
5
+ import {HttpException, HttpMethod, ThrowableResponse} from "../framework";
6
6
  import {RouteHandlerCallable} from "../types";
7
7
  import {Logger} from "@protorians/logger";
8
8
  import {RaitonConfig} from "./config";
@@ -14,7 +14,7 @@ export class Application implements ApplicationInterface {
14
14
 
15
15
  readonly version: string = RaitonConfig.get('version') || '0.0.1'
16
16
 
17
- static get container(): typeof Injection{
17
+ static get container(): typeof Injection {
18
18
  return Injection;
19
19
  }
20
20
 
@@ -162,16 +162,41 @@ export class Application implements ApplicationInterface {
162
162
  (context as any).params = route.parameters;
163
163
  let responses = await route.handler(context)
164
164
 
165
+ if (responses instanceof ThrowableResponse) {
166
+ context.reply.status(responses.statusCode ?? 500)
167
+ }
168
+ if (responses instanceof HttpException) {
169
+ context.reply.status(responses.statusCode ?? 500)
170
+ }
171
+
165
172
  context.reply.send(responses)
166
173
  } catch (e: any) {
167
- Logger.error('Failed to handle request', e.message ?? e)
174
+ Logger.info(`${req.method} ${req.url}`)
175
+ Logger.error('Failed to execute handle', e.message ?? e)
168
176
  if (this.config.develop) {
169
177
  console.error(e)
170
178
  }
179
+ context.reply.status(500)
180
+ context.reply.send({error: true, statusCode: 500, data: null})
171
181
  }
172
182
  }
173
183
 
174
- await this.root.middleware.run(ctx, handler)
175
- await this.root.hooks.run('onResponse', ctx)
184
+ try {
185
+ await this.root.middleware.run(ctx, handler)
186
+ await this.root.hooks.run('onResponse', ctx)
187
+ } catch (err: any) {
188
+ Logger.info(`${req.method} ${req.url}`)
189
+ if (err instanceof HttpException || err instanceof ThrowableResponse) {
190
+ Logger.error(`Server error`, err.message ?? err);
191
+ ctx.reply.status(err.statusCode ?? 500)
192
+ return ctx.reply.send(err.render())
193
+ }
194
+ ctx.reply.send({
195
+ statusCode: 500,
196
+ error: true,
197
+ message: err.message ?? err,
198
+ data: null
199
+ })
200
+ }
176
201
  }
177
202
  }
@@ -1,4 +1,4 @@
1
- import {RaitonConfig} from "@/core";
1
+ import {RaitonConfig} from "../config/config";
2
2
 
3
3
  export class Artifact {
4
4
 
@@ -25,17 +25,13 @@ export function createHandler(
25
25
  return responses;
26
26
  } catch (err: any) {
27
27
 
28
- if (!(err instanceof ThrowableResponse)) {
29
- Logger.error(`Failed to execute ${handlerName} handler`, err.message ?? err);
30
- ctx.reply.status(500)
31
- }
32
-
33
- if (err instanceof ThrowableResponse) {
34
- ctx.reply.status(err.statusCode || 201)
35
- }
28
+ Logger.info(`${ctx.req?.method} ${ctx.req?.url}`)
36
29
 
37
- if (err instanceof HttpException || err instanceof ThrowableResponse)
30
+ if (err instanceof HttpException || err instanceof ThrowableResponse) {
31
+ Logger.error(`Failed to execute ${handlerName} handler`, err.message ?? err);
32
+ ctx.reply.status(err.statusCode ?? 500)
38
33
  return err.render()
34
+ }
39
35
 
40
36
  return {
41
37
  statusCode: 500,
@@ -1,8 +1,7 @@
1
1
  import {MiddlewareCallable, ParamMetaInterface, RouteMetaInterface} from "../../types";
2
2
  import {middlewareCompose} from "../../core";
3
3
  import {validate} from "class-validator";
4
- import {parseCookie} from "@/framework/utilities/cookie.util";
5
- import {DataTransferObject, METADATA_KEYS, Parametrable, Throwable, ViewModel} from "@/framework";
4
+ import {DataTransferObject, METADATA_KEYS, Parametrable, parseCookie, Throwable, ViewModel} from "../../framework";
6
5
 
7
6
  /**
8
7
  * Helper function for collecting arguments from route parameters
@@ -15,4 +15,6 @@ export const METADATA_KEYS = {
15
15
  API_TAGS: Symbol('api:tags'),
16
16
  API_OPERATION: Symbol('api:operation'),
17
17
  API_SECURITY: Symbol('api:security'),
18
+ // Route interaction metadata key
19
+ ROUTE_INTERACTION: Symbol('route:interaction'),
18
20
  }
@@ -6,4 +6,5 @@ export * from "./parametrable.decorator"
6
6
  export * from "./injection.decorator"
7
7
  export * from "./guard.decorator"
8
8
  export * from "./api-response.decorator"
9
- export * from "./api.decorator"
9
+ export * from "./api.decorator"
10
+ export * from "./route-interaction.decorator"
@@ -0,0 +1,188 @@
1
+ import "reflect-metadata";
2
+ import {METADATA_KEYS} from "../constants/decorators.constant";
3
+ import {getControllerMetadata} from "../../core/controller";
4
+ import {RouteInteractionsSubscriber} from "../../types/router";
5
+ import { Raiton } from "../../core/raiton";
6
+
7
+ /**
8
+ * Represents a route interaction that can be rendered with context data
9
+ */
10
+ export class RouteInteractionDescriptor {
11
+ constructor(private template: string) {
12
+ }
13
+
14
+ /**
15
+ * Renders the interaction template with the provided context data
16
+ * Supports nested object paths using dot notation (e.g., [user.firstname])
17
+ * @param context Object containing values for template placeholders
18
+ * @returns Rendered interaction string with placeholders replaced by context values
19
+ */
20
+ render(context: Record<string, any> = {}): string {
21
+ let result = this.template;
22
+
23
+ // Extract all placeholders from the template
24
+ const placeholderRegex = /\[([^\]]+)\]/g;
25
+ let match;
26
+
27
+ while ((match = placeholderRegex.exec(this.template)) !== null) {
28
+ const placeholder = match[0];
29
+ const path = match[1];
30
+
31
+ // Get the value from context using dot notation (e.g., user.firstname)
32
+ const value = this.getNestedValue(context, path);
33
+ const stringValue = value !== null && value !== undefined ? String(value) : '';
34
+
35
+ // result = result.replace(new RegExp(`\\${placeholder.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`, 'g'), stringValue);
36
+ result = result.replace(new RegExp(placeholder.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'), stringValue);
37
+ }
38
+
39
+ return result;
40
+ }
41
+
42
+ /**
43
+ * Get a nested value from an object using dot notation
44
+ * @param obj The object to traverse
45
+ * @param path The dot-notation path (e.g., "user.firstname")
46
+ * @returns The value at the path, or undefined if not found
47
+ */
48
+ private getNestedValue(obj: Record<string, any>, path: string): any {
49
+ return path.split('.').reduce((current, key) => {
50
+ return current?.[key];
51
+ }, obj);
52
+ }
53
+
54
+ /**
55
+ * Get the raw template string
56
+ */
57
+ getTemplate(): string {
58
+ return this.template;
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Global registry of route interactions indexed by their full paths
64
+ */
65
+ class RouteInteractionsRegistry {
66
+ private static readonly interactions = new Map<string, RouteInteractionDescriptor>();
67
+ public static readonly subscribers = new Set<RouteInteractionsSubscriber>();
68
+
69
+ static subscribe(target: any, propertyKey: string) {
70
+ this.subscribers.add({target, propertyKey});
71
+ return this;
72
+ }
73
+
74
+ /**
75
+ * Register a route interaction
76
+ * @param fullPath The complete route path (prefix + method path)
77
+ * @param descriptor The route interaction descriptor
78
+ */
79
+ static register(fullPath: string, descriptor: RouteInteractionDescriptor): typeof this {
80
+ this.interactions.set(fullPath, descriptor);
81
+ return this;
82
+ }
83
+
84
+ /**
85
+ * Get a route interaction by its full path
86
+ * @param fullPath The complete route path
87
+ * @returns The interaction descriptor, or undefined if not found
88
+ */
89
+ static get(fullPath: string): RouteInteractionDescriptor | undefined {
90
+ return this.interactions.get(fullPath);
91
+ }
92
+
93
+ /**
94
+ * Get all registered interactions
95
+ */
96
+ static getAll(): Map<string, RouteInteractionDescriptor> {
97
+ return new Map(this.interactions);
98
+ }
99
+
100
+ /**
101
+ * Clear all registered interactions
102
+ */
103
+ static clear(): void {
104
+ this.interactions.clear();
105
+ }
106
+
107
+ /**
108
+ * Check if an interaction is registered
109
+ */
110
+ static has(fullPath: string): boolean {
111
+ return this.interactions.has(fullPath);
112
+ }
113
+ }
114
+
115
+ /**
116
+ * Public API for accessing route interactions
117
+ */
118
+ export class RouteInteractions {
119
+ /**
120
+ * Get a route interaction by its full path
121
+ * @param path The complete route path (e.g., "/auth/sign-in/index")
122
+ * @returns The interaction descriptor with a render method, or undefined if not found
123
+ */
124
+ static get(path: string): RouteInteractionDescriptor | undefined {
125
+ return RouteInteractionsRegistry.get(path) || this.upsert(path);
126
+ }
127
+
128
+ /**
129
+ * Get all registered route interactions
130
+ */
131
+ static getAll(): Map<string, RouteInteractionDescriptor> {
132
+ return RouteInteractionsRegistry.getAll();
133
+ }
134
+
135
+ private static upsert(pathname: string): RouteInteractionDescriptor | undefined {
136
+ const subscribers = RouteInteractionsRegistry.subscribers.values();
137
+
138
+ for (const subscriber of subscribers) {
139
+ const controller = getControllerMetadata(subscriber.target);
140
+ if (!controller) continue;
141
+
142
+ const route = controller.routes.find(r => r.propertyKey === subscriber.propertyKey);
143
+
144
+ if (!route) continue;
145
+
146
+ const interactions = Reflect.getMetadata(METADATA_KEYS.ROUTE_INTERACTION, subscriber.target)
147
+ if (!interactions) continue;
148
+
149
+ const description = interactions[subscriber.propertyKey]?.description ?? undefined;
150
+ if (!description) continue;
151
+
152
+ const appPrefix = Raiton.thread?.application?.config.prefix
153
+ const fullPath = appPrefix + (controller.prefix || '') + route.path;
154
+
155
+ if(fullPath !== pathname) continue;
156
+
157
+ const descriptor = new RouteInteractionDescriptor(description);
158
+ RouteInteractionsRegistry.register(fullPath, descriptor);
159
+
160
+
161
+ return descriptor;
162
+ }
163
+
164
+ return undefined;
165
+ }
166
+ }
167
+
168
+ /**
169
+ * Decorator to add interaction description to a route method
170
+ * @param description The interaction description template (e.g., "[user] est désormais connecté")
171
+ */
172
+ export function RouteInteraction(description: string) {
173
+ return (target: any, propertyKey: string) => {
174
+ RouteInteractionsRegistry.subscribe(target, propertyKey);
175
+
176
+ // Also store it in metadata for reference during development/inspection
177
+ const interactions = Reflect.getMetadata(METADATA_KEYS.ROUTE_INTERACTION, target) || {};
178
+ interactions[propertyKey] = {
179
+ description,
180
+ // fullPath,
181
+ // descriptor,
182
+ };
183
+ Reflect.defineMetadata(METADATA_KEYS.ROUTE_INTERACTION, interactions, target);
184
+ };
185
+ }
186
+
187
+ // Export the registry for internal use and testing
188
+ export {RouteInteractionsRegistry};
@@ -24,18 +24,18 @@ function createSocketEventDecorator(type: SocketEventType, name?: string) {
24
24
  }
25
25
  }
26
26
 
27
- export function OnConnect() {
27
+ export function OnSocketConnect() {
28
28
  return createSocketEventDecorator('connect')
29
29
  }
30
30
 
31
- export function OnDisconnect() {
31
+ export function OnSocketDisconnect() {
32
32
  return createSocketEventDecorator('disconnect')
33
33
  }
34
34
 
35
- export function OnMessage(name?: string) {
35
+ export function OnSocketMessage(name?: string) {
36
36
  return createSocketEventDecorator('message', name)
37
37
  }
38
38
 
39
- export function OnEvent(name: string) {
39
+ export function OnSocketEvent(name: string) {
40
40
  return createSocketEventDecorator('event', name)
41
41
  }
@@ -7,14 +7,31 @@ export class HttpException extends Error {
7
7
  constructor(
8
8
  error: string | HttpResponseBaseInterface | Error,
9
9
  public statusCode: HttpStatus = HttpStatus.INTERNAL_SERVER_ERROR,
10
+ public errorCode: number | string | symbol | undefined = undefined,
10
11
  ) {
11
12
  super(typeof error === 'string' ? error : error.message);
12
13
  }
13
14
 
15
+ setStatus(statusCode: HttpStatus) {
16
+ this.statusCode = statusCode;
17
+ return this;
18
+ }
19
+
20
+ setErrorCode(code: number | string | symbol | undefined) {
21
+ this.errorCode = code;
22
+ return this;
23
+ }
24
+
25
+ setMessage(error: string | HttpResponseBaseInterface | Error) {
26
+ this.message = typeof error === 'string' ? error : error.message;
27
+ return this;
28
+ }
29
+
14
30
  render() {
15
31
  return {
16
32
  message: this.message,
17
33
  statusCode: this.statusCode,
34
+ errorCode: this.errorCode,
18
35
  error: true,
19
36
  stack: Raiton.thread?.builder?.options?.serve
20
37
  ? this.stack?.split('\n').map(e => e.trim())
@@ -9,3 +9,8 @@ export interface RouteDefinitionInterface {
9
9
  version?: string
10
10
  handler: RouteHandlerCallable
11
11
  }
12
+
13
+ export interface RouteInteractionsSubscriber{
14
+ target: Function;
15
+ propertyKey: string;
16
+ }
@@ -1,5 +1,5 @@
1
1
  import {BuilderInterface} from "./builder";
2
- import {RuntimeAdapterInterface} from "./runtime";
2
+ import {RuntimeAdapterInterface, RuntimeServerInterface} from "./runtime";
3
3
  import {ApplicationInterface} from "./application";
4
4
  import {RuntimeType} from "../framework/enums/runtime.enum";
5
5
 
@@ -13,6 +13,9 @@ export type ThreadWaitCallable = () => (boolean | Promise<boolean>)
13
13
  export interface ThreadInterface {
14
14
  readonly appDir: string;
15
15
  readonly builder: BuilderInterface;
16
+ application: ApplicationInterface | null;
17
+ runtime: RuntimeAdapterInterface | null;
18
+ runtimeServer: RuntimeServerInterface | null;
16
19
 
17
20
  setup(options: ThreadSetupOptionsInterface): this
18
21
 
@@ -1,53 +0,0 @@
1
- import { Controller, Get } from '@protorians/framework';
2
- import { ApiOkResponse, ApiCreatedResponse, ApiBadRequestResponse, ApiResponse } from '@protorians/framework/decorators';
3
-
4
- @Controller('/users')
5
- export class UserController {
6
- // Example 1: Using ApiOkResponse to specify a 200 response with a specific type
7
- @Get()
8
- @ApiOkResponse({
9
- description='Returns a list of users',
10
- type: Array,
11
- isArray: true
12
- })
13
- async getUsers() {
14
- return [{ id: 1, name: 'John Doe' }, { id: 2, name: 'Jane Smith' }];
15
- }
16
-
17
- // Example 2: Using ApiCreatedResponse for a POST endpoint (would need @Post decorator)
18
- // @Post()
19
- // @ApiCreatedResponse({
20
- // description='User created successfully',
21
- // type: Object
22
- // })
23
- // async createUser() {
24
- // // ... implementation
25
- // }
26
-
27
- // Example 3: Using ApiResponse for multiple response types
28
- @Get('/:id')
29
- @ApiResponse({
30
- status: 200,
31
- description='Returns the user if found',
32
- type: Object
33
- })
34
- @ApiResponse({
35
- status: 404,
36
- description='User not found'
37
- })
38
- @ApiResponse({
39
- status: 500,
40
- description='Internal server error'
41
- })
42
- async getUserById() {
43
- // ... implementation
44
- return { id: 1, name: 'John Doe' };
45
- }
46
-
47
- // Example 4: Using the shorthand decorators
48
- @Get('/health')
49
- @ApiOkResponse({ description='API is healthy' })
50
- async healthCheck() {
51
- return { status: 'OK' };
52
- }
53
- }