raiton 3.0.1 → 3.1.0
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 +15 -15
- package/README.md +1 -1
- package/build/bin/index.mjs +240 -2
- package/package.json +3 -4
- package/scripts/update-version.ts +5 -5
- package/source/bin/bootstrapper.ts +3 -3
- package/source/bin/cli-tools.ts +1 -1
- package/source/bin/cli.ts +1 -1
- package/source/commands/artifact.command.ts +3 -3
- package/source/commands/build.command.ts +3 -3
- package/source/commands/develop.command.ts +3 -3
- package/source/commands/grafts.command.ts +1 -1
- package/source/commands/start.command.ts +3 -3
- package/source/core/application.ts +23 -18
- package/source/core/builder.ts +8 -8
- package/source/core/bytes.util.ts +2 -2
- package/source/core/config/config.ts +8 -8
- package/source/core/config/define.ts +4 -4
- package/source/core/context.ts +1 -1
- package/source/core/controller/builder.ts +6 -6
- package/source/core/controller/compiler.ts +5 -5
- package/source/core/controller/metadata.ts +2 -2
- package/source/core/directories.ts +1 -1
- package/source/core/guards.ts +43 -0
- package/source/core/hooks.ts +4 -4
- package/source/core/injection/injection.ts +8 -7
- package/source/core/middleware/compose.ts +2 -2
- package/source/core/middleware/pipeline.ts +2 -2
- package/source/core/plugins/plugin.ts +3 -3
- package/source/core/plugins/scope.ts +3 -3
- package/source/core/raiton.ts +2 -2
- package/source/core/router/handler.ts +7 -7
- package/source/core/router/matcher.ts +1 -1
- package/source/core/router/route.ts +3 -3
- package/source/core/router/router.ts +5 -5
- package/source/core/server.ts +3 -3
- package/source/core/thread.ts +14 -13
- package/source/sdk/artifacts.ts +5 -5
- package/source/sdk/decorators/controllable.decorator.ts +3 -3
- package/source/sdk/decorators/guard.decorator.ts +23 -0
- package/source/sdk/decorators/index.ts +2 -1
- package/source/sdk/decorators/injection.decorator.ts +4 -4
- package/source/sdk/decorators/middleware.decorator.ts +2 -2
- package/source/sdk/decorators/parametrable.ts +3 -3
- package/source/sdk/decorators/routable.decorator.ts +3 -3
- package/source/sdk/encryption.ts +15 -15
- package/source/sdk/env.ts +5 -5
- package/source/sdk/exceptions/http-exception.ts +3 -3
- package/source/sdk/parameter-bag.ts +1 -1
- package/source/sdk/plugins/body-parser.plugin.ts +5 -5
- package/source/sdk/plugins/security/body-limit.ts +3 -3
- package/source/sdk/plugins/security/cors.ts +3 -3
- package/source/sdk/plugins/security/headers.ts +3 -3
- package/source/sdk/plugins/security/method-guard.ts +3 -3
- package/source/sdk/plugins/security/rate-limit.ts +3 -3
- package/source/sdk/repositories.ts +1 -1
- package/source/sdk/responses/error.ts +2 -2
- package/source/sdk/responses/helpers.ts +3 -3
- package/source/sdk/responses/http-throwable.ts +3 -3
- package/source/sdk/responses/http.ts +3 -3
- package/source/sdk/runtime/bun/server.ts +1 -1
- package/source/sdk/runtime/deno/server.ts +1 -1
- package/source/sdk/runtime/index.ts +6 -6
- package/source/sdk/runtime/node/server.ts +1 -1
- package/source/sdk/runtime/web/server.ts +1 -1
- package/source/sdk/utilities/utilities.util.ts +2 -2
- package/source/types/application.ts +5 -5
- package/source/types/artifact.ts +2 -43
- package/source/types/builder.ts +5 -5
- package/source/types/config.ts +3 -3
- package/source/types/controller.ts +6 -6
- package/source/types/contruct.ts +1 -1
- package/source/types/core.ts +3 -5
- package/source/types/directory.ts +1 -1
- package/source/types/encryption.ts +21 -12
- package/source/types/generic.ts +2 -2
- package/source/types/guard.ts +12 -0
- package/source/types/index.ts +1 -3
- package/source/types/injection.ts +2 -2
- package/source/types/lifecycle.ts +3 -3
- package/source/types/middleware.ts +5 -5
- package/source/types/plugin.ts +4 -6
- package/source/types/raiton.ts +3 -3
- package/source/types/responses.ts +10 -7
- package/source/types/router.ts +5 -5
- package/source/types/runtime.ts +1 -1
- package/source/types/server.ts +3 -3
- package/source/types/thread.ts +7 -7
- package/source/types/utilities.ts +1 -1
- package/source/types/values.ts +2 -2
- package/source/types/access-guards.ts +0 -4
- package/source/types/http-responses.ts +0 -8
- package/source/types/scheme.ts +0 -153
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {RequestContext} from "
|
|
1
|
+
import {RequestContext} from "../core/context";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
export type
|
|
4
|
+
export type MiddlewareNextCallable = () => Promise<void>
|
|
5
5
|
|
|
6
6
|
export interface MiddlewareSetupInterface {
|
|
7
7
|
setup: any,
|
|
8
8
|
name: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export interface
|
|
11
|
+
export interface MiddlewareParametersInterface {
|
|
12
12
|
context: RequestContext;
|
|
13
|
-
next:
|
|
13
|
+
next: MiddlewareNextCallable;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export type MiddlewareCallable = (parameters:
|
|
16
|
+
export type MiddlewareCallable = (parameters: MiddlewareParametersInterface) => Promise<any> | void
|
|
17
17
|
|
|
18
18
|
export type MiddlewareType = MiddlewareCallable | MiddlewareSetupInterface
|
package/source/types/plugin.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {PluginScope} from "
|
|
1
|
+
import {PluginScope} from "../core/plugins/scope";
|
|
2
2
|
|
|
3
|
-
export type
|
|
4
|
-
scope: PluginScope
|
|
5
|
-
) => Promise<void> | void
|
|
3
|
+
export type PluginCallable = (scope: PluginScope) => Promise<void> | void
|
|
6
4
|
|
|
7
|
-
export interface
|
|
5
|
+
export interface PluginInterface {
|
|
8
6
|
name?: string
|
|
9
|
-
setup:
|
|
7
|
+
setup: PluginCallable
|
|
10
8
|
}
|
package/source/types/raiton.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {BuilderHMRDeclarationInterface} from "./builder";
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface RaitonSignalMapInterface {
|
|
4
4
|
ready?: undefined;
|
|
5
5
|
errors: any;
|
|
6
|
-
'hmr:controller':
|
|
6
|
+
'hmr:controller': BuilderHMRDeclarationInterface;
|
|
7
7
|
}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import {HttpStatus} from "
|
|
1
|
+
import {HttpStatus} from "../sdk/enums/http-status.enum";
|
|
2
|
+
import {ParseableEntriesType, ParseableType} from "./parseable";
|
|
2
3
|
|
|
3
4
|
export interface HttpResponseBaseInterface {
|
|
4
5
|
message: string;
|
|
5
6
|
statusCode?: HttpStatus;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
|
-
export interface HttpResponseInterface<T = any> extends HttpResponseBaseInterface{
|
|
9
|
-
error?: boolean;
|
|
10
|
-
errorStack?: Error | ErrorResponseInterface[];
|
|
11
|
-
data?: T
|
|
12
|
-
}
|
|
13
|
-
|
|
14
9
|
export interface ErrorResponseInterface {
|
|
15
10
|
id: string;
|
|
16
11
|
message?: string;
|
|
@@ -18,3 +13,11 @@ export interface ErrorResponseInterface {
|
|
|
18
13
|
statusCode?: HttpStatus;
|
|
19
14
|
error?: Error
|
|
20
15
|
}
|
|
16
|
+
|
|
17
|
+
export interface HttpResponseInterface<T extends ParseableType> extends ParseableEntriesType {
|
|
18
|
+
statusCode: number,
|
|
19
|
+
message?: string,
|
|
20
|
+
data?: T,
|
|
21
|
+
error?: any,
|
|
22
|
+
errorStack?: Error | ErrorResponseInterface[];
|
|
23
|
+
}
|
package/source/types/router.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {RequestContext} from "
|
|
2
|
-
import {HttpMethod} from "
|
|
1
|
+
import {RequestContext} from "../core/context";
|
|
2
|
+
import {HttpMethod} from "../sdk";
|
|
3
3
|
|
|
4
|
-
export type
|
|
4
|
+
export type RouteHandlerCallable = (ctx: RequestContext) => Promise<any> | any
|
|
5
5
|
|
|
6
|
-
export interface
|
|
6
|
+
export interface RouteDefinitionInterface {
|
|
7
7
|
method: HttpMethod
|
|
8
8
|
path: string
|
|
9
9
|
version?: string
|
|
10
|
-
handler:
|
|
10
|
+
handler: RouteHandlerCallable
|
|
11
11
|
}
|
package/source/types/runtime.ts
CHANGED
package/source/types/server.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export interface ServerInterface {
|
|
2
|
-
readonly options:
|
|
2
|
+
readonly options: ServerOptionsInterface;
|
|
3
3
|
|
|
4
|
-
option<K extends keyof
|
|
4
|
+
option<K extends keyof ServerOptionsInterface>(key: K): ServerOptionsInterface[K];
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export interface
|
|
7
|
+
export interface ServerOptionsInterface {
|
|
8
8
|
os?: string;
|
|
9
9
|
arch?: string;
|
|
10
10
|
ip?: string;
|
package/source/types/thread.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {BuilderInterface} from "
|
|
2
|
-
import {RuntimeAdapterInterface} from "
|
|
3
|
-
import {ApplicationInterface} from "
|
|
4
|
-
import {RuntimeType} from "
|
|
1
|
+
import {BuilderInterface} from "./builder";
|
|
2
|
+
import {RuntimeAdapterInterface} from "./runtime";
|
|
3
|
+
import {ApplicationInterface} from "./application";
|
|
4
|
+
import {RuntimeType} from "../sdk/enums/runtime.enum";
|
|
5
5
|
|
|
6
|
-
export interface
|
|
6
|
+
export interface ThreadSetupOptionsInterface {
|
|
7
7
|
application: ApplicationInterface;
|
|
8
8
|
runtime?: RuntimeType
|
|
9
9
|
}
|
|
@@ -14,7 +14,7 @@ export interface ThreadInterface {
|
|
|
14
14
|
readonly appDir: string;
|
|
15
15
|
readonly builder: BuilderInterface;
|
|
16
16
|
|
|
17
|
-
setup(options:
|
|
17
|
+
setup(options: ThreadSetupOptionsInterface): this
|
|
18
18
|
|
|
19
19
|
run(): Promise<this>;
|
|
20
20
|
|
|
@@ -28,4 +28,4 @@ export interface ThreadInterface {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
export interface
|
|
31
|
+
export interface ThreadOptionsInterface {}
|
package/source/types/values.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
export type
|
|
3
|
-
export type
|
|
2
|
+
export type StringType = string | Object | null | undefined;
|
|
3
|
+
export type StringableType = StringType | StringType[] | Promise<StringType | StringType[]>;
|
package/source/types/scheme.ts
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import {TObject, TProperties, TSchema} from "@sinclair/typebox";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export interface ISchemePropertyOptions {
|
|
5
|
-
optional?: boolean;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The `ISchematic` interface provides a structured contract for managing and constructing schemas
|
|
10
|
-
* that define the shape of request bodies, parameters, query strings, and response structures.
|
|
11
|
-
* It allows dynamic assignment of schema properties and the retrieval of constructed schema configurations.
|
|
12
|
-
*
|
|
13
|
-
* @template TBody The schema type defining the request body.
|
|
14
|
-
* @template TParams The schema type defining the request parameters.
|
|
15
|
-
* @template TQuery The schema type defining the query string.
|
|
16
|
-
* @template TResponse The schema type defining the response structure, indexed by HTTP status codes.
|
|
17
|
-
*/
|
|
18
|
-
export interface IScheme<
|
|
19
|
-
TBody extends TSchema | undefined = undefined,
|
|
20
|
-
TParams extends TSchema | undefined = undefined,
|
|
21
|
-
TQuery extends TSchema | undefined = undefined,
|
|
22
|
-
TResponse extends Record<number, TSchema> | undefined = undefined
|
|
23
|
-
> {
|
|
24
|
-
/**
|
|
25
|
-
* Retrieves the value of the `$body` property.
|
|
26
|
-
*
|
|
27
|
-
* @return {TBody | undefined} The body content of type `TBody` or `undefined` if not set.
|
|
28
|
-
*/
|
|
29
|
-
get $body(): TBody | undefined;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Updates the body of the request with a specified key-value pair.
|
|
33
|
-
*
|
|
34
|
-
* @param {string} key - The key to be added or updated in the body of the request.
|
|
35
|
-
* @param {TProperties} value - The value associated with the specified key.
|
|
36
|
-
* @return {this} The current instance to allow method chaining.
|
|
37
|
-
*/
|
|
38
|
-
body(key: string, value: TProperties): this;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Retrieves the current value of `$params`.
|
|
42
|
-
*
|
|
43
|
-
* This method returns the parameter(s) associated with the instance.
|
|
44
|
-
* It may return undefined if no parameters are set.
|
|
45
|
-
*
|
|
46
|
-
* @return {TParams | undefined} The current parameters or undefined if none are set.
|
|
47
|
-
*/
|
|
48
|
-
get $params(): TParams | undefined;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Assigns a key-value pair to the parameters of the current instance.
|
|
52
|
-
*
|
|
53
|
-
* @param {string} key - The key for the parameter to be set.
|
|
54
|
-
* @param {TProperties} value - The value associated with the specified key.
|
|
55
|
-
* @return {this} The current instance with the updated parameter.
|
|
56
|
-
*/
|
|
57
|
-
params(key: string, value: TProperties): this;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Retrieves the query string associated with the current object.
|
|
61
|
-
*
|
|
62
|
-
* @return {TQuery | undefined} The query string if defined, otherwise undefined.
|
|
63
|
-
*/
|
|
64
|
-
get $querystring(): TQuery | undefined;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Updates or sets a query string parameter with the specified key and value.
|
|
68
|
-
* If the query string already contains the key, its value will be updated.
|
|
69
|
-
*
|
|
70
|
-
* @param {string} key - The key of the query string parameter to be updated or added.
|
|
71
|
-
* @param {TProperties} value - The value to be set for the specified query string key.
|
|
72
|
-
* @return {this} The current instance to allow for method chaining.
|
|
73
|
-
*/
|
|
74
|
-
querystring(key: string, value: TProperties): this;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Retrieves the response object associated with the instance.
|
|
78
|
-
*
|
|
79
|
-
* @return {TResponse | undefined} The response object if it exists, otherwise undefined.
|
|
80
|
-
*/
|
|
81
|
-
get $response(): TResponse | undefined;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Stores a key-value pair in the response object and returns the current instance for chaining.
|
|
85
|
-
*
|
|
86
|
-
* @param {number} key - The unique identifier for the value to be stored.
|
|
87
|
-
* @param {TProperties} value - The value to store associated with the provided key.
|
|
88
|
-
* @return {this} Returns the current instance to allow method chaining.
|
|
89
|
-
*/
|
|
90
|
-
response(key: number, value: TProperties): this;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Provides the schema options for handling the request and response structure.
|
|
94
|
-
*
|
|
95
|
-
* @return {ISchemeOptions<TBody, TParams, TQuery, TResponse>} The schema options defining the types for body, params, query, and response.
|
|
96
|
-
*/
|
|
97
|
-
schema(): ISchemeOptions<TBody, TParams, TQuery, TResponse>;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Interface representing the schema configuration for various aspects of a request-response process.
|
|
102
|
-
*
|
|
103
|
-
* @template TBody Represents the schema for the request body. Defaults to undefined if not specified.
|
|
104
|
-
* @template TParams Represents the schema for request parameters. Defaults to undefined if not specified.
|
|
105
|
-
* @template TQuery Represents the schema for query string parameters. Defaults to undefined if not specified.
|
|
106
|
-
* @template TResponse Represents the schema for response objects, mapped by status codes. Defaults to undefined if not specified.
|
|
107
|
-
*
|
|
108
|
-
* @property {TBody} [body] Optional schema definition for the request body.
|
|
109
|
-
* @property {TParams} [params] Optional schema definition for the request parameters.
|
|
110
|
-
* @property {TQuery} [querystring] Optional schema definition for query string parameters.
|
|
111
|
-
* @property {TResponse} [response] Optional schema definition for response objects, associated with HTTP status codes.
|
|
112
|
-
*/
|
|
113
|
-
export interface ISchemeConfig<
|
|
114
|
-
TBody extends TSchema | undefined = undefined,
|
|
115
|
-
TParams extends TSchema | undefined = undefined,
|
|
116
|
-
TQuery extends TSchema | undefined = undefined,
|
|
117
|
-
TResponse extends Record<number, TSchema> | undefined = undefined
|
|
118
|
-
> {
|
|
119
|
-
body?: TBody;
|
|
120
|
-
params?: TParams;
|
|
121
|
-
querystring?: TQuery;
|
|
122
|
-
response?: TResponse;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Interface representing schema options for defining request and response payloads
|
|
127
|
-
* in a structured and strongly-typed manner.
|
|
128
|
-
*
|
|
129
|
-
* @template TBody - The type of the schema for the request body, or undefined if not applicable.
|
|
130
|
-
* @template TParams - The type of the schema for the request parameters, or undefined if not applicable.
|
|
131
|
-
* @template TQuery - The type of the schema for the query string, or undefined if not applicable.
|
|
132
|
-
* @template TResponse - A record of HTTP status codes to their respective response schemas, or undefined if not applicable.
|
|
133
|
-
*
|
|
134
|
-
* @property body - Represents the schema definition for the request body.
|
|
135
|
-
* This is an optional property and only applies if TBody is specified.
|
|
136
|
-
* @property params - Represents the schema definition for the request parameters.
|
|
137
|
-
* This is an optional property and only applies if TParams is specified.
|
|
138
|
-
* @property querystring - Represents the schema definition for the query string.
|
|
139
|
-
* This is an optional property and only applies if TQuery is specified.
|
|
140
|
-
* @property response - Represents the schema definition for the response body, mapped by status code.
|
|
141
|
-
* This is an optional property and only applies if TResponse is specified.
|
|
142
|
-
*/
|
|
143
|
-
export interface ISchemeOptions<
|
|
144
|
-
TBody extends TSchema | undefined = undefined,
|
|
145
|
-
TParams extends TSchema | undefined = undefined,
|
|
146
|
-
TQuery extends TSchema | undefined = undefined,
|
|
147
|
-
TResponse extends Record<number, TSchema> | undefined = undefined
|
|
148
|
-
> {
|
|
149
|
-
body?: TObject<NonNullable<TBody>> | undefined;
|
|
150
|
-
params?: TObject<NonNullable<TParams>> | undefined;
|
|
151
|
-
querystring?: TObject<NonNullable<TQuery>> | undefined;
|
|
152
|
-
response?: TObject<NonNullable<TResponse>> | undefined;
|
|
153
|
-
}
|