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
@@ -0,0 +1,101 @@
1
+ import {LBadge, Logger} from "@protorians/logger";
2
+ import {EventBus, EventBusEnum} from "@protorians/events-bus";
3
+
4
+ /**
5
+ * Represents a throwable error that extends the built-in JavaScript Error class.
6
+ * The Throwable class provides utility methods for triggering different levels
7
+ * of error notifications, including error, warning, and critical errors.
8
+ *
9
+ * The class dispatches error notifications via the EventBus and optionally
10
+ * throws an exception or exits the application depending on the severity level
11
+ * or the provided parameters.
12
+ */
13
+ export class Throwable extends Error {
14
+ constructor(message: string, protected statusCode: number = 500, label?: string) {
15
+ super(message);
16
+ this.name = 'Throwable';
17
+ if (label) Logger.debug(LBadge.debug(label), message);
18
+ EventBus.dispatch(EventBusEnum.SERVER_THROW, {error: this})
19
+ }
20
+
21
+ /**
22
+ * Dispatches a system server error event and optionally throws an error.
23
+ *
24
+ * @param {string} message - The error message to be dispatched and potentially thrown.
25
+ * @param {boolean} [soft=true] - Determines whether the error should be thrown. If true, the error is only dispatched. If false, the error is dispatched and then thrown.
26
+ * @param statusCode
27
+ * @return {void} This method does not return a value.
28
+ */
29
+ static error(message: string, soft: boolean = true, statusCode: number = 500): void {
30
+ EventBus.dispatch(EventBusEnum.SERVER_ERROR, {message, soft})
31
+ if (!soft) throw new Throwable(message, statusCode, 'ERR');
32
+ }
33
+
34
+ /**
35
+ * Emits a system server warning event and optionally throws an error based on the severity of the warning.
36
+ *
37
+ * @param {string} message - The warning message to be dispatched and possibly thrown as an error.
38
+ * @param {boolean} [soft=true] - Determines whether the warning should be treated as non-critical (soft). If false, an error is thrown.
39
+ * @param statusCode
40
+ * @return {void} This method does not return a value.
41
+ */
42
+ static warning(message: string, soft: boolean = true, statusCode: number = 500): void {
43
+ EventBus.dispatch(EventBusEnum.SERVER_WARNING, {message, soft})
44
+ if (!soft) throw new Throwable(message, statusCode, 'WRN');
45
+ }
46
+
47
+ /**
48
+ * Triggers a critical system event, dispatching an alert message and terminating the process.
49
+ *
50
+ * @param {string} message - The critical error message to be dispatched with the event.
51
+ * @return {void} This method does not return a value as it terminates the process.
52
+ */
53
+ static critical(message: string): void {
54
+ Logger.debug(LBadge.debug('CRITICAL'), message);
55
+ EventBus.dispatch(EventBusEnum.SERVER_CRITICAL, {message})
56
+ process.exit(1);
57
+ }
58
+ }
59
+
60
+ /**
61
+ * A function that throws an error with a provided message and a specified error type.
62
+ *
63
+ * @param {string} message - The error message to be used when throwing the error.
64
+ * @param {boolean} [soft=true] - Determines whether the error is categorized as "soft".
65
+ * If true, it will be treated as a soft error. Defaults to true.
66
+ * @param statusCode
67
+ * @returns {void}
68
+ */
69
+ export const throwError = (message: string, soft: boolean = true, statusCode: number = 500): void => Throwable.error(message, soft, statusCode);
70
+
71
+ /**
72
+ * Function to throw an error with a specified message.
73
+ *
74
+ * @param {string} message - The error message to be used in the thrown error.
75
+ * @param statusCode
76
+ * @throws {Throwable} always throw an error with the provided message.
77
+ */
78
+ export const throwException = (message: string, statusCode: number = 500): void => throwError(message, false, statusCode);
79
+
80
+ /**
81
+ * Emits a warning with the specified message and behavior.
82
+ *
83
+ * @param {string} message - The warning message to be displayed.
84
+ * @param {boolean} [soft=true] - Indicates whether the warning should be soft (true)
85
+ * or treated as a harder warning (false). Defaults to true.
86
+ * @param statusCode
87
+ * @returns {void} This function does not return any value.
88
+ */
89
+ export const throwWarning = (message: string, soft: boolean = true, statusCode: number = 500): void =>
90
+ Throwable.warning(message, soft, statusCode);
91
+
92
+ /**
93
+ * A variable representing a function that throws a critical error.
94
+ *
95
+ * This function is used to trigger a critical error by providing a specific message.
96
+ * It encapsulates the logic for generating a throwable critical error through the `Throwable.critical` method.
97
+ *
98
+ * @param {string} message - The error message describing the critical error to be thrown.
99
+ * @returns {Throwable} The critical throwable generated with the provided message.
100
+ */
101
+ export const throwCritical = (message: string): void => Throwable.critical(message);
@@ -0,0 +1,5 @@
1
+ import * as fastifyCore from 'fastify'
2
+ import fastifyPlugin from 'fastify-plugin'
3
+
4
+ export const FastifyPlugin = fastifyPlugin;
5
+ export default {...fastifyCore};
@@ -1,6 +1,13 @@
1
1
  export * from "./enums/index"
2
2
  export * from "./constants/index"
3
3
  export * from "./decorators/index"
4
+ export * from "./responses/index"
4
5
  export * from "./plugins/index"
5
6
  export * from "./utilities/index"
6
7
  export * from "./runtime/index"
8
+ export * from "./controllers"
9
+ export * from "./data-transfer-object"
10
+ export * from "./encryption"
11
+ export * from "./parameter-bag"
12
+ export * from "./repositories"
13
+ export * from "./services"
@@ -1,12 +1,12 @@
1
- import {ParseableEntriesType, ParseablePrimitiveType} from "../types/parseable";
1
+ import {IParseableEntries, IParseablePrimitiveEntry} from "../types/parseable";
2
2
  import {stabilizeJson} from "./utilities";
3
3
 
4
4
 
5
- export class Json<T extends ParseableEntriesType> {
5
+ export class Json<T extends IParseableEntries> {
6
6
 
7
7
  public readonly stack: Map<keyof T, T[keyof T]> = new Map();
8
8
 
9
- constructor(json: ParseablePrimitiveType<T>) {
9
+ constructor(json: IParseablePrimitiveEntry<T>) {
10
10
  this.records(stabilizeJson<T>(json));
11
11
  }
12
12
 
@@ -43,13 +43,13 @@ export class Json<T extends ParseableEntriesType> {
43
43
  return stabilizeJson<T>(json);
44
44
  }
45
45
 
46
- static from<T extends ParseableEntriesType>(data: T): Json<T> {
46
+ static from<T extends IParseableEntries>(data: T): Json<T> {
47
47
  const json = new Json<T>(null);
48
48
  json.records(data);
49
49
  return json;
50
50
  }
51
51
 
52
- static records<T extends ParseableEntriesType>(support: Json<T>, data: ParseablePrimitiveType<T>): Json<T> {
52
+ static records<T extends IParseableEntries>(support: Json<T>, data: IParseablePrimitiveEntry<T>): Json<T> {
53
53
  return support.records(this.stabilize(data));
54
54
  }
55
55
  }
@@ -0,0 +1,55 @@
1
+ import {ParseableEntriesType, ParseablePrimitiveType} from "@/types";
2
+ import {stabilizeJson} from "./utilities";
3
+ import {DynamicParameter, IDynamicParameters, IDynamicProps, IParameter,} from "@protorians/parameters";
4
+
5
+
6
+ export class ParameterBag<T extends ParseableEntriesType> {
7
+
8
+ protected _bag: IDynamicParameters<any>;
9
+
10
+ constructor(data: T) {
11
+ this._bag = new DynamicParameter(this.initializeData(data));
12
+ }
13
+
14
+ protected initializeData(data: T): any {
15
+ const prepared = {} as IDynamicProps<T>
16
+
17
+ for (const [key, value] of Object.entries(data)) {
18
+ prepared[key as keyof T] = {
19
+ value,
20
+ } as IParameter<T[keyof T]>
21
+ }
22
+
23
+ return prepared
24
+ }
25
+
26
+ get bag(): IDynamicParameters<any> {
27
+ return this._bag;
28
+ }
29
+
30
+ records(data: T): this {
31
+ for (const [key, value] of Object.entries(data))
32
+ this._bag.update(key as keyof T, value);
33
+ return this;
34
+ }
35
+
36
+ render(): T {
37
+ return Object.fromEntries(this._bag.stack) as any as T;
38
+ }
39
+
40
+ toString(): string {
41
+ return JSON.stringify(this.render());
42
+ }
43
+
44
+ static stabilize<T>(json: string | T | null): T {
45
+ return stabilizeJson<T>(json);
46
+ }
47
+
48
+ static from<T extends IDynamicProps<T>>(data: T): ParameterBag<T> {
49
+ return new ParameterBag<T>(data);
50
+ }
51
+
52
+ static records<T extends IDynamicProps<T>>(support: ParameterBag<T>, data: ParseablePrimitiveType<T>): ParameterBag<T> {
53
+ return support.records(this.stabilize(data));
54
+ }
55
+ }
@@ -1,4 +1,4 @@
1
- import {Throwable} from "./throwable";
1
+ import {Throwable} from "@/sdk/exceptions";
2
2
 
3
3
 
4
4
  export class DelegateRepository {
@@ -0,0 +1,52 @@
1
+ import type {ErrorResponseInterface} from "@/types";
2
+ import {HttpResponse} from "@/sdk/responses/http";
3
+
4
+
5
+ export class HttpErrorResponse {
6
+ public readonly stack: Map<string, ErrorResponseInterface> = new Map();
7
+
8
+ public get entries(): ErrorResponseInterface[] {
9
+ return [...this.stack.values()];
10
+ }
11
+
12
+ public add(input: ErrorResponseInterface): this {
13
+ this.stack.set(input.id, input)
14
+ return this;
15
+ }
16
+
17
+ public remove(id: string): this {
18
+ this.stack.delete(id);
19
+ return this;
20
+ }
21
+
22
+ public get(id: string): ErrorResponseInterface | undefined {
23
+ return this.stack.get(id);
24
+ }
25
+
26
+ public has(id: string): boolean {
27
+ return this.stack.has(id);
28
+ }
29
+
30
+ public clear(): this {
31
+ this.stack.clear();
32
+ return this;
33
+ }
34
+
35
+ public get empty(): boolean {
36
+ return this.stack.size === 0;
37
+ }
38
+
39
+ public get existence(): number {
40
+ return this.stack.size
41
+ }
42
+
43
+ public push() {
44
+ const first = this.stack.values().next().value;
45
+ HttpResponse.push({
46
+ statusCode: 500,
47
+ message: first?.message || 'Internal server error',
48
+ error: true,
49
+ errorStack: this.entries
50
+ })
51
+ }
52
+ }
@@ -0,0 +1,28 @@
1
+ import {HttpResponse, HttpStatus} from "@/sdk";
2
+ import {HttpResponseInterface} from "@/types";
3
+ import {Raiton} from "@/core";
4
+
5
+
6
+ export function RaitonResponses(
7
+ message: string,
8
+ data: HttpResponseInterface,
9
+ statusCode: HttpStatus,
10
+ metadata?: Omit<HttpResponseInterface<any>, 'data' | 'message' | 'statusCode'>
11
+ ) {
12
+
13
+ if (metadata) {
14
+ metadata.error = typeof data.error === 'boolean' ? data.error : false
15
+ metadata.errorStack = (metadata.errorStack instanceof Error)
16
+ ? metadata.errorStack
17
+ : (Raiton.thread?.builder?.options?.development
18
+ ? (Array.isArray(metadata.errorStack) ? metadata.errorStack : [])
19
+ : undefined)
20
+ }
21
+
22
+ return {
23
+ ...metadata,
24
+ statusCode,
25
+ message,
26
+ data,
27
+ }
28
+ }
@@ -0,0 +1,28 @@
1
+ import {HttpResponseInterface} from "@/types";
2
+ import {HttpStatus} from "@/sdk/enums";
3
+ import {Raiton} from "@/core";
4
+
5
+
6
+ export class ThrowableResponse extends Error {
7
+ constructor(
8
+ public input: string | HttpResponseInterface,
9
+ public statusCode: HttpStatus = HttpStatus.INTERNAL_SERVER_ERROR,
10
+ ) {
11
+ super(typeof input === 'string' ? input : input.message);
12
+ }
13
+
14
+ render() {
15
+ const stack = typeof this.input === 'object' ? this.input.errorStack : undefined
16
+ return {
17
+ message: this.message,
18
+ statusCode: this.statusCode,
19
+ data: (typeof this.input === 'object') ? this.input.data : undefined,
20
+ error: (typeof this.input === 'object') ? this.input.error : false,
21
+ stack: stack instanceof Error ?
22
+ (Raiton.thread?.builder?.options?.development
23
+ ? this.stack?.split('\n').map(e => e.trim())
24
+ : undefined)
25
+ : stack
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,48 @@
1
+ import {HttpResponseInterface} from "@/types";
2
+ import {HttpStatus} from "@/sdk/enums";
3
+ import {ThrowableResponse} from "@/sdk";
4
+
5
+
6
+ export class HttpResponse {
7
+ public static push(response: Partial<HttpResponseInterface>): void {
8
+ throw new ThrowableResponse({
9
+ statusCode: response.statusCode || HttpStatus.BAD_REQUEST,
10
+ message: response.message || 'No response message provided',
11
+ data: response.data,
12
+ error: response.error,
13
+ errorStack: response.errorStack
14
+ })
15
+ }
16
+
17
+ constructor(public readonly response: HttpResponseInterface) {
18
+ }
19
+
20
+ status(statusCode: HttpStatus): this {
21
+ this.response.statusCode = statusCode;
22
+ return this;
23
+ }
24
+
25
+ message(message: string) {
26
+ this.response.message = message;
27
+ return this;
28
+ }
29
+
30
+ data(data: any) {
31
+ this.response.data = data;
32
+ return this;
33
+ }
34
+
35
+ error(error: boolean) {
36
+ this.response.error = error;
37
+ return this;
38
+ }
39
+
40
+ stack(stack: Error) {
41
+ this.response.errorStack = stack
42
+ return this;
43
+ }
44
+
45
+ render(): HttpResponseInterface {
46
+ return (new ThrowableResponse({...this.response})).render()
47
+ }
48
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./error"
2
+ export * from "./http-throwable"
3
+ export * from "./http"
4
+ export * from "./helpers"
@@ -1,7 +1,6 @@
1
- import type {IHttpResponse, ParseableType, ResponseParameters} from "@/types";
2
- import {RequestContext} from "@/core/context";
1
+ import type {IHttpResponse, IParseableEntry} from "@/types";
3
2
 
4
- export function httpResponse<T extends ParseableType>(
3
+ export function httpResponse<T extends IParseableEntry>(
5
4
  statusCode: number,
6
5
  message?: string,
7
6
  data?: T,
@@ -15,7 +14,7 @@ export function httpResponse<T extends ParseableType>(
15
14
  }
16
15
  }
17
16
 
18
- export function successResponse<T extends ParseableType>(
17
+ export function successResponse<T extends IParseableEntry>(
19
18
  message?: string,
20
19
  data?: T,
21
20
  error?: any,
@@ -23,23 +22,10 @@ export function successResponse<T extends ParseableType>(
23
22
  return httpResponse<T>(200, message, data, error);
24
23
  }
25
24
 
26
- export function errorResponse<T extends ParseableType>(
25
+ export function errorResponse<T extends IParseableEntry>(
27
26
  message?: string,
28
27
  data?: T,
29
28
  error?: any,
30
29
  ): IHttpResponse<T> {
31
30
  return httpResponse<T>(500, message, data, error);
32
31
  }
33
-
34
-
35
- export class RaitonResponse {
36
- constructor(
37
- public readonly parameters: ResponseParameters,
38
- public readonly context: RequestContext,
39
- ) {
40
- }
41
-
42
- parse(){
43
-
44
- }
45
- }
@@ -0,0 +1,21 @@
1
+ import path from "node:path";
2
+ import * as fs from "node:fs";
3
+ import {FastifyInstance} from "fastify";
4
+ import {aliasPath} from "./utilities";
5
+
6
+
7
+ export async function registryRoutes(app: FastifyInstance) {
8
+ const dir = aliasPath('@/routes');
9
+ if (!dir || !fs.existsSync(dir)) return app;
10
+
11
+ const files = fs.readdirSync(dir);
12
+
13
+ for (const file of files) {
14
+ if (file.endsWith(".route.ts")) {
15
+ const route = await import(path.join(dir, file));
16
+ route.default(app);
17
+ }
18
+ }
19
+
20
+ return app;
21
+ }
@@ -9,9 +9,10 @@ export const bunRuntime: RuntimeAdapterInterface = {
9
9
  let server: any
10
10
 
11
11
  return {
12
- async listen(port) {
12
+ async listen(port, hostname) {
13
13
  server = Bun.serve({
14
14
  port,
15
+ hostname,
15
16
  fetch: async (request: Request) => {
16
17
  let responseBody: any
17
18
  let statusCode = 200
@@ -5,13 +5,13 @@ export const denoRuntime: RuntimeAdapterInterface = {
5
5
  let controller: AbortController
6
6
 
7
7
  return {
8
- async listen(port) {
8
+ async listen(port, hostname) {
9
9
  if (typeof Deno === 'undefined') throw new Error(
10
10
  'Deno is not installed, please run `deno install -A -f --unstable https://deno.land/x/raiton/cli.ts`'
11
11
  )
12
12
 
13
13
  controller = new AbortController()
14
- Deno.serve({port, signal: controller.signal}, async (req: any) => {
14
+ Deno.serve({port, hostname, signal: controller.signal}, async (req: any) => {
15
15
  let body: any
16
16
  let status = 200
17
17
  const headers = new Headers()
@@ -45,9 +45,9 @@ export const nodeRuntime: RuntimeAdapterInterface = {
45
45
  })
46
46
 
47
47
  return {
48
- listen(port) {
48
+ listen(port, hostname) {
49
49
  return new Promise((resolve) =>
50
- server.listen(port, resolve)
50
+ server.listen(port, hostname, resolve)
51
51
  )
52
52
  },
53
53
  close() {
@@ -25,7 +25,7 @@ export type SchematicCast<T> = T extends Scheme<any, any, any, any>
25
25
 
26
26
  /**
27
27
  * Represents a schema configuration that can be used with type-safe operations
28
- * and is compatible with route options.
28
+ * and is compatible with fastify route options.
29
29
  *
30
30
  * @template TBody - Optional schema type for the request body.
31
31
  * @template TParams - Optional schema type for the route parameters.
@@ -0,0 +1,18 @@
1
+ export function isControllerArtifact(filename: string) {
2
+ return isArtifact(filename, 'controller')
3
+ }
4
+
5
+
6
+ export function isServiceArtifact(filename: string) {
7
+ return isArtifact(filename, 'service')
8
+ }
9
+
10
+ export function isArtifact(filename: string, artifact: string) {
11
+ return [
12
+ filename.endsWith(`.${artifact}.ts`),
13
+ filename.endsWith(`.${artifact}.js`),
14
+ filename.endsWith(`.${artifact}.mjs`),
15
+ filename.endsWith(`.${artifact}.cjs`),
16
+ ].some(Boolean)
17
+ }
18
+
@@ -1,7 +1,5 @@
1
- // export * from "./alias-path.util"
2
- export * from "./artifacts.util"
3
1
  export * from "./callable.util"
4
2
  export * from "./utilities.util"
5
- export * from "./controller.util"
3
+ export * from "./artifact.util"
6
4
  export * from "./json.util"
7
5
  export * from "./path.util"
@@ -0,0 +1,61 @@
1
+ // import {Parametrable} from "@/sdk/enums";
2
+ // import {FastifyReply, FastifyRequest} from "fastify";
3
+ // import {RouteParametersMetadataInterface} from "@/types/parameters";
4
+ // // import {MultipartFile} from "@fastify/multipart";
5
+ //
6
+ // export async function parseParametersArguments(
7
+ // req: FastifyRequest,
8
+ // res: FastifyReply,
9
+ // metadata: RouteParametersMetadataInterface[]
10
+ // ): Promise<any[]> {
11
+ // const args: any[] = [];
12
+ // const files: AsyncIterableIterator<any> | any[] = ('files' in req && typeof req.files === 'function') ? req.files() : [];
13
+ //
14
+ // for (const param of metadata) {
15
+ // switch (param.type) {
16
+ // // case Parametrable.APP:
17
+ // // args[param.index] = req.server as any;
18
+ // // break;
19
+ // case Parametrable.PARAM:
20
+ // args[param.index] = param.key ? (req.params as any)[param.key] : req.params;
21
+ // break;
22
+ // case Parametrable.BODY:
23
+ // args[param.index] = param.key ? (req.body as any)[param.key] : req.body;
24
+ // break;
25
+ // case Parametrable.QUERY:
26
+ // args[param.index] = param.key ? (req.query as any)[param.key] : req.query;
27
+ // break;
28
+ // case Parametrable.HEADER:
29
+ // args[param.index] = req.headers[param.key.toLowerCase()] as any;
30
+ // break;
31
+ // case Parametrable.REQ:
32
+ // args[param.index] = req as any;
33
+ // break;
34
+ // case Parametrable.REPLY:
35
+ // args[param.index] = res as any;
36
+ // break;
37
+ // case Parametrable.UPLOAD_FILE:
38
+ // let accumulate: any = param.multiple ? [] : null;
39
+ // for await (const part of files) {
40
+ // if (param.key === part.fieldname) {
41
+ // const packed = {
42
+ // filename: part.filename,
43
+ // mimetype: part.mimetype,
44
+ // encoding: part.encoding,
45
+ // toFile: () => part.file,
46
+ // toBuffer: async () => await part.toBuffer(),
47
+ // }
48
+ // accumulate = param.multiple ? [...accumulate, packed] : packed;
49
+ // }
50
+ // }
51
+ // args[param.index] = accumulate as any;
52
+ // break;
53
+ //
54
+ // case Parametrable.CUSTOM:
55
+ // args[param.index] = param.callable?.({request: req, reply: res, files}) ?? null;
56
+ // break;
57
+ // }
58
+ // }
59
+ //
60
+ // return args;
61
+ // }
@@ -16,9 +16,9 @@ export interface ApplicationInterface {
16
16
 
17
17
  get hostname(): string;
18
18
 
19
- // setOption<K extends keyof ApplicationConfig>(key: K, value: ApplicationConfig[K]): this;
20
- //
21
- // setOptions(options: ApplicationConfig): this;
19
+ setOption<K extends keyof ApplicationConfig>(key: K, value: ApplicationConfig[K]): this;
20
+
21
+ setOptions(options: ApplicationConfig): this;
22
22
 
23
23
  register(plugin: any): this;
24
24