@bool-ts/core 1.3.2 → 1.4.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.
Files changed (68) hide show
  1. package/.prettierrc +11 -0
  2. package/LICENSE +21 -21
  3. package/__test/controller.ts +66 -79
  4. package/__test/index.ts +8 -11
  5. package/__test/interfaces.ts +7 -7
  6. package/__test/module.ts +16 -17
  7. package/__test/repository.ts +16 -16
  8. package/__test/service.ts +20 -20
  9. package/bun.lockb +0 -0
  10. package/dist/decorators/arguments.d.ts +31 -0
  11. package/dist/decorators/arguments.js +67 -0
  12. package/dist/decorators/controller.d.ts +2 -2
  13. package/dist/decorators/controller.js +6 -10
  14. package/dist/decorators/http.d.ts +1 -1
  15. package/dist/decorators/http.js +16 -103
  16. package/dist/decorators/index.d.ts +1 -0
  17. package/dist/decorators/index.js +7 -26
  18. package/dist/decorators/inject.js +5 -9
  19. package/dist/decorators/injectable.d.ts +2 -2
  20. package/dist/decorators/injectable.js +4 -8
  21. package/dist/decorators/module.d.ts +4 -2
  22. package/dist/decorators/module.js +4 -8
  23. package/dist/decorators/zodSchema.d.ts +1 -1
  24. package/dist/decorators/zodSchema.js +5 -8
  25. package/dist/entities/index.d.ts +3 -0
  26. package/dist/entities/index.js +3 -0
  27. package/dist/entities/route.d.ts +101 -0
  28. package/dist/entities/route.js +257 -0
  29. package/dist/entities/router.d.ts +10 -0
  30. package/dist/entities/router.js +25 -0
  31. package/dist/entities/routerGroup.d.ts +14 -0
  32. package/dist/entities/routerGroup.js +24 -0
  33. package/dist/hooks/factory.d.ts +12 -12
  34. package/dist/hooks/factory.js +180 -151
  35. package/dist/hooks/index.js +2 -7
  36. package/dist/hooks/injector.js +7 -10
  37. package/dist/http/clientError.d.ts +1 -1
  38. package/dist/http/clientError.js +3 -7
  39. package/dist/http/index.d.ts +12 -2
  40. package/dist/http/index.js +34 -73
  41. package/dist/http/serverError.js +3 -7
  42. package/dist/index.js +5 -21
  43. package/dist/interfaces/index.js +1 -3
  44. package/dist/ultils/asyncFunction.js +1 -4
  45. package/dist/ultils/index.js +1 -17
  46. package/package.json +30 -33
  47. package/src/decorators/arguments.ts +128 -0
  48. package/src/decorators/controller.ts +14 -18
  49. package/src/decorators/http.ts +81 -195
  50. package/src/decorators/index.ts +7 -6
  51. package/src/decorators/inject.ts +13 -19
  52. package/src/decorators/injectable.ts +11 -12
  53. package/src/decorators/module.ts +21 -22
  54. package/src/decorators/zodSchema.ts +20 -27
  55. package/src/entities/index.ts +3 -0
  56. package/src/entities/route.ts +328 -0
  57. package/src/entities/router.ts +35 -0
  58. package/src/entities/routerGroup.ts +34 -0
  59. package/src/hooks/factory.ts +285 -205
  60. package/src/hooks/index.ts +2 -2
  61. package/src/hooks/injector.ts +43 -43
  62. package/src/http/clientError.ts +45 -56
  63. package/src/http/index.ts +63 -72
  64. package/src/http/serverError.ts +38 -38
  65. package/src/index.ts +6 -6
  66. package/src/interfaces/index.ts +3 -3
  67. package/test.http +30 -28
  68. package/tsconfig.json +107 -109
package/.prettierrc ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "semi": true,
3
+ "tabWidth": 4,
4
+ "printWidth": 128,
5
+ "singleQuote": false,
6
+ "singleAttributePerLine": false,
7
+ "trailingComma": "none",
8
+ "bracketSameLine": true,
9
+ "bracketSpacing": true,
10
+ "htmlWhitespaceSensitivity": "ignore"
11
+ }
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 BoolTS
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 BoolTS
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,79 +1,66 @@
1
- import type { IService } from "./interfaces";
2
-
3
- import * as Zod from "zod";
4
-
5
- import { Controller, Delete, Get, Inject, Options, Patch, Post, Put, ZodSchema } from "../src";
6
- import { TestService } from "./service";
7
- import { Request, Response } from "express";
8
-
9
-
10
- const getAbcSchema = Zod.object({
11
- headers: Zod.object({
12
- authorization: Zod.string().min(10)
13
- })
14
- });
15
-
16
- const stringSchema = Zod.object({}).refine(async (val) => {
17
- const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
18
- await delay(10000);
19
-
20
- return val;
21
- });
22
-
23
- @Controller("test")
24
- export class TestController {
25
- constructor(
26
- @Inject(TestService) private readonly testService: IService
27
- ) { }
28
-
29
- @Get("abc")
30
- private _get(
31
- @ZodSchema(getAbcSchema) req: Request,
32
- res: Response
33
- ) {
34
- console.log("this.testService", this.testService.exec())
35
- res.json({ test: "success" }).send();
36
- }
37
-
38
- @Post("abc")
39
- private _post(
40
- @ZodSchema(getAbcSchema) req: Request,
41
- res: Response
42
- ) {
43
- console.log("req.body", req.body);
44
- res.json({ test: "success" }).send();
45
- }
46
-
47
- @Put()
48
- private _put(
49
- @ZodSchema(getAbcSchema) req: Request,
50
- res: Response
51
- ) {
52
- res.json({ test: "success" }).send();
53
- }
54
-
55
- @Patch("abc/:id")
56
- private _patch(
57
- @ZodSchema(getAbcSchema) req: Request,
58
- res: Response
59
- ) {
60
- console.log(req.params)
61
- res.json({ test: "success" }).send();
62
- }
63
-
64
- @Delete()
65
- private _delete(
66
- req: Request,
67
- @ZodSchema(stringSchema) res: Response
68
- ) {
69
- res.json({ test: "success" }).send();
70
- }
71
-
72
- @Options()
73
- private _options(
74
- @ZodSchema(getAbcSchema) req: Request,
75
- res: Response
76
- ) {
77
- res.json({ test: "success" }).send();
78
- }
79
- }
1
+ import type { IService } from "./interfaces";
2
+
3
+ import * as Zod from "zod";
4
+
5
+ import { Body, Controller, Delete, Get, Inject, Options, Params, Patch, Post, Put, ZodSchema } from "../src";
6
+ import { TestService } from "./service";
7
+
8
+ const postParamsSchema = Zod.object({
9
+ id: Zod.string(),
10
+ providerId: Zod.string().uuid()
11
+ });
12
+
13
+ const bodySchema = Zod.object({
14
+ data: Zod.object({
15
+ name: Zod.string(),
16
+ age: Zod.number()
17
+ })
18
+ });
19
+
20
+ const requestSchema = Zod.object({
21
+ headers: Zod.object({
22
+ authorization: Zod.string().min(10)
23
+ }),
24
+ body: bodySchema
25
+ });
26
+
27
+ const stringSchema = Zod.object({}).refine(async (val) => {
28
+ const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
29
+ await delay(10000);
30
+
31
+ return val;
32
+ });
33
+
34
+ @Controller("test")
35
+ export class TestController {
36
+ constructor(@Inject(TestService) private readonly testService: IService) {}
37
+
38
+ @Get("abc")
39
+ public get(req: Request) {
40
+ console.log("HEHE");
41
+ console.log("this.testService", this.testService.exec());
42
+ }
43
+
44
+ @Post("abc/:id/provider/:providerId")
45
+ public async post(
46
+ @Params(undefined, postParamsSchema)
47
+ params: any,
48
+ @Body(bodySchema)
49
+ req: Zod.infer<typeof bodySchema>
50
+ ) {
51
+ console.log("req.headers", req);
52
+ console.log("===========================");
53
+ }
54
+
55
+ @Put()
56
+ public put(req: any) {}
57
+
58
+ @Patch("abc/:testId")
59
+ public patch(req: Request) {}
60
+
61
+ @Delete()
62
+ public delete(req: Request) {}
63
+
64
+ @Options()
65
+ public options(req: Request) {}
66
+ }
package/__test/index.ts CHANGED
@@ -1,11 +1,8 @@
1
- import "reflect-metadata";
2
-
3
- import { BoolFactory } from "../src";
4
- import { TestModule } from "./module";
5
-
6
-
7
- const app = BoolFactory(TestModule);
8
-
9
- app.listen(3000, () => {
10
- console.log(`Listening on port ${3000}...`);
11
- });
1
+ import "reflect-metadata";
2
+
3
+ import { BoolFactory } from "../src";
4
+ import { TestModule } from "./module";
5
+
6
+ BoolFactory(TestModule, {
7
+ port: 3000
8
+ });
@@ -1,7 +1,7 @@
1
- export interface IRepository {
2
- exec(): void;
3
- }
4
-
5
- export interface IService {
6
- exec(): void;
7
- }
1
+ export interface IRepository {
2
+ exec(): void;
3
+ }
4
+
5
+ export interface IService {
6
+ exec(): void;
7
+ }
package/__test/module.ts CHANGED
@@ -1,17 +1,16 @@
1
- import { Module } from "../src";
2
- import { TestController } from "./controller";
3
- // import { TestRepository } from "./repository";
4
- import { TestService } from "./service";
5
-
6
- @Module({
7
- controllers: [
8
- TestController
9
- ],
10
- dependencies: [
11
- // TestService,
12
- // TestRepository
13
- ]
14
- })
15
- export class TestModule { }
16
-
17
- export default TestModule;
1
+ import { Module } from "../src";
2
+ import { TestController } from "./controller";
3
+ // import { TestRepository } from "./repository";
4
+ import { TestService } from "./service";
5
+
6
+ @Module({
7
+ allowOrigins: ["http://localhost:7000"],
8
+ controllers: [TestController],
9
+ dependencies: [
10
+ // TestService,
11
+ // TestRepository
12
+ ]
13
+ })
14
+ export class TestModule {}
15
+
16
+ export default TestModule;
@@ -1,16 +1,16 @@
1
- import type { IRepository } from "./interfaces";
2
-
3
- import { Injectable } from "../src";
4
-
5
-
6
- @Injectable()
7
- export class TestRepository implements IRepository {
8
- /**
9
- *
10
- */
11
- exec() {
12
- console.log("This is test repository.");
13
- }
14
- }
15
-
16
- export default TestRepository;
1
+ import type { IRepository } from "./interfaces";
2
+
3
+ import { Injectable } from "../src";
4
+
5
+
6
+ @Injectable()
7
+ export class TestRepository implements IRepository {
8
+ /**
9
+ *
10
+ */
11
+ exec() {
12
+ console.log("This is test repository.");
13
+ }
14
+ }
15
+
16
+ export default TestRepository;
package/__test/service.ts CHANGED
@@ -1,20 +1,20 @@
1
- import type { IService, IRepository } from "./interfaces";
2
-
3
- import { Inject, Injectable } from "../src";
4
- import { TestRepository } from "./repository";
5
-
6
-
7
- @Injectable()
8
- export class TestService implements IService {
9
- constructor(
10
- @Inject(TestRepository) private readonly testRepository: IRepository
11
- ) { }
12
-
13
- /**
14
- *
15
- */
16
- exec() {
17
- console.log("This is test service.", this.testRepository);
18
- this.testRepository.exec();
19
- }
20
- }
1
+ import type { IService, IRepository } from "./interfaces";
2
+
3
+ import { Inject, Injectable } from "../src";
4
+ import { TestRepository } from "./repository";
5
+
6
+
7
+ @Injectable()
8
+ export class TestService implements IService {
9
+ constructor(
10
+ @Inject(TestRepository) private readonly testRepository: IRepository
11
+ ) { }
12
+
13
+ /**
14
+ *
15
+ */
16
+ exec() {
17
+ console.log("This is test service.", this.testRepository);
18
+ this.testRepository.exec();
19
+ }
20
+ }
package/bun.lockb CHANGED
Binary file
@@ -0,0 +1,31 @@
1
+ import * as Zod from "zod";
2
+ export declare enum EArgumentTypes {
3
+ headers = "HEADERS",
4
+ body = "BODY",
5
+ params = "PARAMS",
6
+ query = "QUERY"
7
+ }
8
+ export type TMetadata = {
9
+ index: number;
10
+ type: EArgumentTypes.headers;
11
+ zodSchema?: Zod.Schema;
12
+ } | {
13
+ index: number;
14
+ type: EArgumentTypes.body;
15
+ zodSchema?: Zod.Schema;
16
+ parser?: "arrayBuffer" | "blob" | "formData" | "json" | "text";
17
+ } | {
18
+ index: number;
19
+ type: EArgumentTypes.params;
20
+ key?: string;
21
+ zodSchema?: Zod.Schema;
22
+ } | {
23
+ index: number;
24
+ type: EArgumentTypes.query;
25
+ zodSchema?: Zod.Schema;
26
+ };
27
+ export declare const controllerActionArgumentsKey: unique symbol;
28
+ export declare const Headers: (zodSchema?: Zod.Schema) => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => void;
29
+ export declare const Body: (zodSchema?: Zod.Schema, parser?: "arrayBuffer" | "blob" | "formData" | "json" | "text") => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => void;
30
+ export declare const Params: (key?: string, zodSchema?: Zod.Schema) => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => void;
31
+ export declare const Query: (zodSchema?: Zod.Schema) => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => void;
@@ -0,0 +1,67 @@
1
+ import * as Zod from "zod";
2
+ export var EArgumentTypes;
3
+ (function (EArgumentTypes) {
4
+ EArgumentTypes["headers"] = "HEADERS";
5
+ EArgumentTypes["body"] = "BODY";
6
+ EArgumentTypes["params"] = "PARAMS";
7
+ EArgumentTypes["query"] = "QUERY";
8
+ })(EArgumentTypes || (EArgumentTypes = {}));
9
+ export const controllerActionArgumentsKey = Symbol.for("__bool:controller.action::arguments__");
10
+ export const Headers = (zodSchema) => {
11
+ return (target, methodName, parameterIndex) => {
12
+ if (!methodName) {
13
+ return;
14
+ }
15
+ const headersMetadata = Reflect.getOwnMetadata(controllerActionArgumentsKey, target.constructor, methodName) || {};
16
+ headersMetadata[`argumentIndexes.${parameterIndex}`] = {
17
+ index: parameterIndex,
18
+ type: EArgumentTypes.headers,
19
+ zodSchema: zodSchema
20
+ };
21
+ Reflect.defineMetadata(controllerActionArgumentsKey, headersMetadata, target.constructor, methodName);
22
+ };
23
+ };
24
+ export const Body = (zodSchema, parser) => {
25
+ return (target, methodName, parameterIndex) => {
26
+ if (!methodName) {
27
+ return;
28
+ }
29
+ const bodyMetadata = Reflect.getOwnMetadata(controllerActionArgumentsKey, target.constructor, methodName) || {};
30
+ bodyMetadata[`argumentIndexes.${parameterIndex}`] = {
31
+ index: parameterIndex,
32
+ type: EArgumentTypes.body,
33
+ zodSchema: zodSchema,
34
+ parser: parser
35
+ };
36
+ Reflect.defineMetadata(controllerActionArgumentsKey, bodyMetadata, target.constructor, methodName);
37
+ };
38
+ };
39
+ export const Params = (key, zodSchema) => {
40
+ return (target, methodName, parameterIndex) => {
41
+ if (!methodName) {
42
+ return;
43
+ }
44
+ const paramsMetadata = Reflect.getOwnMetadata(controllerActionArgumentsKey, target.constructor, methodName) || {};
45
+ paramsMetadata[`argumentIndexes.${parameterIndex}`] = {
46
+ index: parameterIndex,
47
+ type: EArgumentTypes.params,
48
+ key: key,
49
+ zodSchema: zodSchema
50
+ };
51
+ Reflect.defineMetadata(controllerActionArgumentsKey, paramsMetadata, target.constructor, methodName);
52
+ };
53
+ };
54
+ export const Query = (zodSchema) => {
55
+ return (target, methodName, parameterIndex) => {
56
+ if (!methodName) {
57
+ return;
58
+ }
59
+ const queryMetadata = Reflect.getOwnMetadata(controllerActionArgumentsKey, target.constructor, methodName) || {};
60
+ queryMetadata[`argumentIndexes.${parameterIndex}`] = {
61
+ index: parameterIndex,
62
+ type: EArgumentTypes.params,
63
+ zodSchema: zodSchema
64
+ };
65
+ Reflect.defineMetadata(controllerActionArgumentsKey, queryMetadata, target.constructor, methodName);
66
+ };
67
+ };
@@ -1,3 +1,3 @@
1
- export declare const controllerKey = "__bool:controller__";
2
- export declare const Controller: (prefix: string) => <T extends Object>(target: T, context?: ClassDecoratorContext) => T;
1
+ export declare const controllerKey: unique symbol;
2
+ export declare const Controller: (prefix: string) => <T extends Object>(target: T) => T;
3
3
  export default Controller;
@@ -1,12 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Controller = exports.controllerKey = void 0;
4
- const injectable_1 = require("./injectable");
5
- exports.controllerKey = "__bool:controller__";
6
- const Controller = (prefix) => (target, context) => {
7
- Reflect.defineMetadata(exports.controllerKey, !prefix.startsWith("/") ? `/${prefix}` : prefix, target);
8
- Reflect.defineMetadata(injectable_1.injectableKey, undefined, target);
1
+ import { injectableKey } from "./injectable";
2
+ export const controllerKey = Symbol.for("__bool:controller__");
3
+ export const Controller = (prefix) => (target) => {
4
+ Reflect.defineMetadata(controllerKey, !prefix.startsWith("/") ? `/${prefix}` : prefix, target);
5
+ Reflect.defineMetadata(injectableKey, undefined, target);
9
6
  return target;
10
7
  };
11
- exports.Controller = Controller;
12
- exports.default = exports.Controller;
8
+ export default Controller;
@@ -4,7 +4,7 @@ export interface IControllerRoute {
4
4
  methodName: string;
5
5
  descriptor: PropertyDescriptor;
6
6
  }
7
- export declare const controllerRoutesKey = "__bool:controller.routes__";
7
+ export declare const controllerRoutesKey: unique symbol;
8
8
  /**
9
9
  *
10
10
  * @param path
@@ -1,17 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Options = exports.Delete = exports.Patch = exports.Put = exports.Post = exports.Get = exports.controllerRoutesKey = void 0;
4
- const http_1 = require("../http");
5
- const ultils_1 = require("../ultils");
6
- const zodSchema_1 = require("./zodSchema");
7
- exports.controllerRoutesKey = "__bool:controller.routes__";
1
+ export const controllerRoutesKey = Symbol.for("__bool:controller.routes__");
8
2
  const defaultDecorator = (path, method) => (target, methodName, descriptor) => {
9
3
  if (!(descriptor.value instanceof Function)) {
10
- throw Error(`${method} decorator only use for method.`);
4
+ throw Error(`${method} decorator only use for class method.`);
11
5
  }
12
6
  // Define controller metadata
13
- Reflect.defineMetadata(exports.controllerRoutesKey, [
14
- ...Reflect.getOwnMetadata(exports.controllerRoutesKey, target.constructor) || [],
7
+ Reflect.defineMetadata(controllerRoutesKey, [
8
+ ...(Reflect.getOwnMetadata(controllerRoutesKey, target.constructor) || []),
15
9
  {
16
10
  path: !path.startsWith("/") ? `/${path}` : path,
17
11
  httpMethod: method.toUpperCase(),
@@ -19,128 +13,47 @@ const defaultDecorator = (path, method) => (target, methodName, descriptor) => {
19
13
  descriptor: descriptor
20
14
  }
21
15
  ], target.constructor);
22
- // Define route parameters zod validation
23
- const currentMethod = descriptor.value;
24
- const isAsync = descriptor.value instanceof ultils_1.AsyncFunction;
25
- if (!isAsync) {
26
- descriptor.value = function () {
27
- const zodSchemaMetadata = Reflect.getOwnMetadata(zodSchema_1.controllerRouteZodSchemaKey, target.constructor, methodName);
28
- if (zodSchemaMetadata) {
29
- for (const zodSchemaProp in zodSchemaMetadata) {
30
- const tmpZodMetadata = zodSchemaMetadata[zodSchemaProp];
31
- try {
32
- const validation = tmpZodMetadata.schema.safeParse(arguments[tmpZodMetadata.index]);
33
- if (!validation.success) {
34
- throw new http_1.HttpClientError({
35
- httpCode: 400,
36
- message: `Validation at the [${methodName}] method fails at positional argument [${tmpZodMetadata.index}].`,
37
- data: validation.error.issues
38
- });
39
- }
40
- arguments[tmpZodMetadata.index] = validation.data;
41
- }
42
- catch (error) {
43
- if (error instanceof http_1.HttpClientError) {
44
- throw error;
45
- }
46
- throw new http_1.HttpServerError({
47
- httpCode: 500,
48
- message: `Validation at the [${methodName}] method error at positional argument [${tmpZodMetadata.index}].`,
49
- data: !(error instanceof Error) ? error : [{
50
- message: error.message,
51
- code: error.name,
52
- cause: error.cause
53
- }]
54
- });
55
- }
56
- }
57
- }
58
- return currentMethod.apply(this, arguments);
59
- };
60
- }
61
- else {
62
- descriptor.value = async function () {
63
- const zodSchemaMetadata = Reflect.getOwnMetadata(zodSchema_1.controllerRouteZodSchemaKey, target.constructor, methodName);
64
- if (zodSchemaMetadata) {
65
- for (const zodSchemaProp in zodSchemaMetadata) {
66
- const tmpZodMetadata = zodSchemaMetadata[zodSchemaProp];
67
- try {
68
- const validation = await tmpZodMetadata.schema.safeParseAsync(arguments[tmpZodMetadata.index]);
69
- if (!validation.success) {
70
- throw new http_1.HttpClientError({
71
- httpCode: 400,
72
- message: `Validation at the [${methodName}] method fails at positional argument [${tmpZodMetadata.index}].`,
73
- data: validation.error.issues
74
- });
75
- }
76
- arguments[tmpZodMetadata.index] = validation.data;
77
- }
78
- catch (error) {
79
- if (error instanceof http_1.HttpClientError) {
80
- throw error;
81
- }
82
- throw new http_1.HttpServerError({
83
- httpCode: 500,
84
- message: `Validation at the [${methodName}] method error at positional argument [${tmpZodMetadata.index}].`,
85
- data: !(error instanceof Error) ? error : [{
86
- message: error.message,
87
- code: error.name,
88
- cause: error.cause
89
- }]
90
- });
91
- }
92
- }
93
- }
94
- return currentMethod.apply(this, arguments);
95
- };
96
- }
97
16
  };
98
17
  /**
99
18
  *
100
19
  * @param path
101
20
  * @returns
102
21
  */
103
- const Get = (path = "/") => defaultDecorator(path, "Get");
104
- exports.Get = Get;
22
+ export const Get = (path = "/") => defaultDecorator(path, "Get");
105
23
  /**
106
24
  *
107
25
  * @param path
108
26
  * @returns
109
27
  */
110
- const Post = (path = "/") => defaultDecorator(path, "Post");
111
- exports.Post = Post;
28
+ export const Post = (path = "/") => defaultDecorator(path, "Post");
112
29
  /**
113
30
  *
114
31
  * @param path
115
32
  * @returns
116
33
  */
117
- const Put = (path = "/") => defaultDecorator(path, "Put");
118
- exports.Put = Put;
34
+ export const Put = (path = "/") => defaultDecorator(path, "Put");
119
35
  /**
120
36
  *
121
37
  * @param path
122
38
  * @returns
123
39
  */
124
- const Patch = (path = "/") => defaultDecorator(path, "Patch");
125
- exports.Patch = Patch;
40
+ export const Patch = (path = "/") => defaultDecorator(path, "Patch");
126
41
  /**
127
42
  *
128
43
  * @param path
129
44
  * @returns
130
45
  */
131
- const Delete = (path = "/") => defaultDecorator(path, "Delete");
132
- exports.Delete = Delete;
46
+ export const Delete = (path = "/") => defaultDecorator(path, "Delete");
133
47
  /**
134
48
  *
135
49
  * @param path
136
50
  * @returns
137
51
  */
138
- const Options = (path = "/") => defaultDecorator(path, "Options");
139
- exports.Options = Options;
140
- exports.default = {
141
- Get: exports.Get,
142
- Post: exports.Post,
143
- Put: exports.Put,
144
- Patch: exports.Patch,
145
- Delete: exports.Delete
52
+ export const Options = (path = "/") => defaultDecorator(path, "Options");
53
+ export default {
54
+ Get,
55
+ Post,
56
+ Put,
57
+ Patch,
58
+ Delete
146
59
  };
@@ -1,3 +1,4 @@
1
+ export { Headers, Body, Params, Query, EArgumentTypes } from "./arguments";
1
2
  export { Controller, controllerKey } from "./controller";
2
3
  export { Inject, injectKey } from "./inject";
3
4
  export { Injectable, injectableKey } from "./injectable";