raiton 1.0.0-alpha.2 → 1.0.0-alpha.4

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 (68) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +3 -4
  3. package/build/bin/index.mjs +3798 -3644
  4. package/build/raiton-1.0.0-alpha.4.tgz +0 -0
  5. package/deno.json +9 -0
  6. package/package.json +2 -1
  7. package/source/bin/cli-tools.ts +1 -6
  8. package/source/bin/constants.ts +5 -0
  9. package/source/bin/index.ts +1 -1
  10. package/source/commands/develop.command.ts +3 -3
  11. package/source/commands/start.command.ts +1 -1
  12. package/source/core/application.ts +66 -18
  13. package/source/core/builder.ts +27 -21
  14. package/source/core/controller/builder.ts +8 -5
  15. package/source/core/controller/metadata.ts +1 -1
  16. package/source/core/directories.ts +1 -1
  17. package/source/core/index.ts +0 -1
  18. package/source/core/injection/injection.ts +67 -5
  19. package/source/core/injection/metadata.ts +22 -0
  20. package/source/core/middleware/compose.ts +1 -1
  21. package/source/core/raiton.ts +2 -3
  22. package/source/core/router/handler.ts +100 -44
  23. package/source/core/thread.ts +18 -8
  24. package/source/sdk/artifacts.ts +65 -41
  25. package/source/sdk/constants/decorators.constant.ts +1 -0
  26. package/source/sdk/data-transfer-object.ts +11 -3
  27. package/source/sdk/decorators/parametrable.ts +19 -15
  28. package/source/sdk/decorators/routable.decorator.ts +0 -3
  29. package/source/sdk/decorators/routable.ts +25 -0
  30. package/source/sdk/encryption.ts +5 -6
  31. package/source/sdk/enums/encrypted.enum.ts +10 -0
  32. package/source/sdk/enums/http-method.enum.ts +10 -0
  33. package/source/sdk/enums/http-status.enum.ts +73 -0
  34. package/source/sdk/enums/index.ts +2 -1
  35. package/source/sdk/exceptions/http-exception.ts +28 -0
  36. package/source/sdk/exceptions/index.ts +2 -0
  37. package/source/sdk/exceptions/throwable.ts +101 -0
  38. package/source/sdk/fastify.ts +5 -0
  39. package/source/sdk/index.ts +7 -0
  40. package/source/sdk/json.ts +5 -5
  41. package/source/sdk/parameter-bag.ts +55 -0
  42. package/source/sdk/repositories.ts +1 -1
  43. package/source/sdk/responses/error.ts +52 -0
  44. package/source/sdk/responses/helpers.ts +28 -0
  45. package/source/sdk/responses/http-throwable.ts +28 -0
  46. package/source/sdk/responses/http.ts +48 -0
  47. package/source/sdk/responses/index.ts +4 -0
  48. package/source/sdk/responses.ts +4 -18
  49. package/source/sdk/routes.ts +21 -0
  50. package/source/sdk/runtime/bun/server.ts +2 -1
  51. package/source/sdk/runtime/deno/server.ts +2 -2
  52. package/source/sdk/runtime/node/server.ts +2 -2
  53. package/source/sdk/schemes.ts +1 -1
  54. package/source/sdk/utilities/artifact.util.ts +18 -0
  55. package/source/sdk/utilities/index.ts +1 -3
  56. package/source/sdk/utilities/parameters-arguments.util.ts +61 -0
  57. package/source/types/application.ts +3 -3
  58. package/source/types/artifact.ts +36 -32
  59. package/source/types/builder.ts +0 -4
  60. package/source/types/config.ts +2 -2
  61. package/source/types/controller.ts +1 -2
  62. package/source/types/index.ts +2 -3
  63. package/source/types/lifecycle.ts +11 -0
  64. package/source/types/parameters.ts +21 -0
  65. package/source/types/payload.ts +5 -0
  66. package/source/types/responses.ts +17 -7
  67. package/source/types/runtime.ts +1 -1
  68. package/build/raiton-1.0.0-alpha.2.tgz +0 -0
@@ -4,37 +4,41 @@ export interface ArtifactEntry {
4
4
  size: number;
5
5
  }
6
6
 
7
- export type ArtifactDecoratorHandler = () => void;
8
-
9
- export interface ArtifactDecorator {
10
- syntax: RegExp;
11
- handler: ArtifactDecoratorHandler;
12
- }
13
-
14
- export interface ArtifactOptions {
15
- readonly artifact: string;
16
- readonly provider: string;
17
- readonly decorator: ArtifactDecorator;
18
- verbose?: boolean;
19
- }
20
-
21
- export interface ArtifactInterface {
22
- readonly options: ArtifactOptions;
23
- readonly directory: string;
24
- readonly file: string;
25
- readonly workdir: string;
26
-
27
- get files(): string[];
28
-
29
- get extensions(): string[];
30
-
31
- scan(): string[];
32
-
33
- generate(): boolean;
7
+ export interface ArtifactsConfig {
8
+ types: string[]
34
9
  }
35
10
 
36
- export interface ArtifactEntry {
37
- vendor: string;
38
- decorator: string;
39
- pattern: string;
40
- }
11
+ // export type ArtifactDecoratorHandler = () => void;
12
+
13
+ // export interface ArtifactDecorator {
14
+ // syntax: RegExp;
15
+ // handler: ArtifactDecoratorHandler;
16
+ // }
17
+
18
+ // export interface ArtifactOptions {
19
+ // readonly artifact: string;
20
+ // readonly provider: string;
21
+ // readonly decorator: ArtifactDecorator;
22
+ // verbose?: boolean;
23
+ // }
24
+
25
+ // export interface ArtifactInterface {
26
+ // readonly options: ArtifactOptions;
27
+ // readonly directory: string;
28
+ // readonly file: string;
29
+ // readonly workdir: string;
30
+ //
31
+ // get files(): string[];
32
+ //
33
+ // get extensions(): string[];
34
+ //
35
+ // scan(): string[];
36
+ //
37
+ // generate(): boolean;
38
+ // }
39
+
40
+ // export interface ArtifactEntry {
41
+ // vendor: string;
42
+ // decorator: string;
43
+ // pattern: string;
44
+ // }
@@ -1,6 +1,3 @@
1
- import type {BuildContext, BuildOptions, Metafile} from "esbuild";
2
- import {HmrInterface} from "@/types/hmr";
3
- import {ISignalStack} from "@protorians/core";
4
1
  import {WatchEventType} from "node:fs";
5
2
 
6
3
  export interface BuildCommandOptions {
@@ -17,7 +14,6 @@ export type BuilderBootCallable = (builder: BuilderInterface) => Promise<void>
17
14
  export interface BuilderInterface {
18
15
  readonly workdir: string;
19
16
  readonly options: BuilderConfig;
20
- readonly hmr: HmrInterface;
21
17
  // readonly signal: ISignalStack<BuilderSignalMap>;
22
18
 
23
19
  // get context(): BuildContext<BuildOptions> | null;
@@ -1,7 +1,7 @@
1
- import {ArtifactEntry} from "@/types/artifact";
1
+ import type {ArtifactsConfig} from "@/types/artifact";
2
2
 
3
3
  export interface Configurable {
4
4
  rootDir: string;
5
5
  version: string;
6
- artifacts?: ArtifactEntry[]
6
+ artifacts?: ArtifactsConfig
7
7
  }
@@ -5,7 +5,6 @@ import {MiddlewareCallable, MiddlewareType} from "@/types/middleware";
5
5
  export interface ControllerMetaInterface {
6
6
  prefix?: string;
7
7
  routes: RouteMetaInterface[];
8
- params: Record<string, ParamMetaInterface[]>;
9
8
  middlewares: Record<string, MiddlewareCallable[]>;
10
9
  }
11
10
 
@@ -15,7 +14,6 @@ export interface RouteMetaInterface {
15
14
  method: HttpMethod;
16
15
  path: string;
17
16
  propertyKey: string;
18
- params: ParamMetaInterface[];
19
17
  }
20
18
 
21
19
  export interface ParamMetaInterface {
@@ -23,6 +21,7 @@ export interface ParamMetaInterface {
23
21
  type: Parametrable;
24
22
  key?: string;
25
23
  callable?: (ctx: Context) => any;
24
+ metatype?: any;
26
25
  }
27
26
 
28
27
  export interface RouteDecoratorParameters {
@@ -3,7 +3,6 @@ export type * from "./builder"
3
3
  export type * from "./thread"
4
4
  export type * from "./access-guards"
5
5
  export type * from "./contruct"
6
- export type * from "./data-transfer-object"
7
6
  export type * from "./directory"
8
7
  export type * from "./encryption"
9
8
  export type * from "./generic"
@@ -13,7 +12,6 @@ export type * from "./scheme"
13
12
  export type * from "./values"
14
13
  export type * from "./utilities"
15
14
  export type * from "./artifact"
16
- export type * from "./hmr"
17
15
  export type * from "./middleware"
18
16
  export type * from "./core"
19
17
  export type * from "./plugin"
@@ -23,4 +21,5 @@ export type * from "./controller"
23
21
  export type * from "./injection"
24
22
  export type * from "./responses"
25
23
  export type * from "./server"
26
- export type * from "./raiton"
24
+ export type * from "./raiton"
25
+ export type * from "./lifecycle"
@@ -0,0 +1,11 @@
1
+ export interface OnMount {
2
+ onMount(): void | Promise<void>;
3
+ }
4
+
5
+ export interface OnUnmount {
6
+ onUnmount(): void | Promise<void>;
7
+ }
8
+
9
+ export interface OnInit {
10
+ onInit(): void | Promise<void>;
11
+ }
@@ -0,0 +1,21 @@
1
+ import {Parametrable} from "@/sdk/enums/http-parameters.enum";
2
+ import {FastifyReply, FastifyRequest} from "fastify";
3
+ // import {MultipartFile} from "@fastify/multipart";
4
+
5
+
6
+ export interface RouteParametersMetadataPayload {
7
+ request: FastifyRequest;
8
+ reply: FastifyReply;
9
+ files: AsyncIterableIterator<any> | any[]
10
+ }
11
+
12
+ export type RouteParametersMetadataCallable = (payload: RouteParametersMetadataPayload) => any[];
13
+
14
+ export interface RouteParametersMetadataInterface {
15
+ index: number;
16
+ type: Parametrable;
17
+ key: string;
18
+ multiple: boolean;
19
+ optional: boolean;
20
+ callable?: RouteParametersMetadataCallable;
21
+ }
@@ -0,0 +1,5 @@
1
+ import {FastifySchema} from "fastify/types/schema";
2
+
3
+
4
+ export interface IPayload extends FastifySchema{
5
+ }
@@ -1,10 +1,20 @@
1
- import type {ParseableEntriesType} from "@/types/parseable";
1
+ import {HttpStatus} from "@/sdk/enums/http-status.enum";
2
2
 
3
- export interface ResponseParameters {
4
- readonly message?: string;
5
- readonly error?: boolean;
6
- readonly statusCode?: number;
7
- readonly errorStack?: Error;
8
- readonly data?: ParseableEntriesType
3
+ export interface HttpResponseBaseInterface {
4
+ message: string;
5
+ statusCode?: HttpStatus;
9
6
  }
10
7
 
8
+ export interface HttpResponseInterface<T = any> extends HttpResponseBaseInterface{
9
+ error?: boolean;
10
+ errorStack?: Error | ErrorResponseInterface[];
11
+ data?: T
12
+ }
13
+
14
+ export interface ErrorResponseInterface {
15
+ id: string;
16
+ message?: string;
17
+ code?: string;
18
+ statusCode?: HttpStatus;
19
+ error?: Error
20
+ }
@@ -1,7 +1,7 @@
1
1
  import {RuntimeType} from "@/sdk/enums/runtime.enum";
2
2
 
3
3
  export interface RuntimeServerInterface {
4
- listen(port: number): Promise<void>
4
+ listen(port: number, hostname?: string): Promise<void>
5
5
 
6
6
  close(): Promise<void>
7
7
 
Binary file