@bool-ts/core 1.4.1 → 1.5.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 (71) hide show
  1. package/.prettierrc +11 -11
  2. package/LICENSE +21 -21
  3. package/__test/afterDispatcher.ts +9 -0
  4. package/__test/beforeDispatcher.ts +9 -0
  5. package/__test/controller.ts +66 -66
  6. package/__test/firstGuard.ts +10 -0
  7. package/__test/firstMiddleware.ts +9 -0
  8. package/__test/index.ts +8 -8
  9. package/__test/interfaces.ts +7 -7
  10. package/__test/module.ts +25 -16
  11. package/__test/repository.ts +16 -16
  12. package/__test/secondGuard.ts +10 -0
  13. package/__test/secondMiddleware.ts +9 -0
  14. package/__test/service.ts +20 -20
  15. package/bun.lockb +0 -0
  16. package/dist/decorators/arguments.d.ts +12 -6
  17. package/dist/decorators/arguments.js +39 -26
  18. package/dist/decorators/controller.d.ts +9 -1
  19. package/dist/decorators/controller.js +6 -4
  20. package/dist/decorators/dispatcher.d.ts +7 -0
  21. package/dist/decorators/dispatcher.js +9 -0
  22. package/dist/decorators/guard.d.ts +7 -0
  23. package/dist/decorators/guard.js +9 -0
  24. package/dist/decorators/http.d.ts +4 -3
  25. package/dist/decorators/http.js +6 -5
  26. package/dist/decorators/index.d.ts +13 -3
  27. package/dist/decorators/index.js +5 -2
  28. package/dist/decorators/injectable.d.ts +1 -1
  29. package/dist/decorators/injectable.js +1 -4
  30. package/dist/decorators/middleware.d.ts +7 -0
  31. package/dist/decorators/middleware.js +9 -0
  32. package/dist/decorators/module.d.ts +28 -7
  33. package/dist/decorators/module.js +48 -1
  34. package/dist/entities/route.d.ts +5 -5
  35. package/dist/entities/routerGroup.d.ts +1 -1
  36. package/dist/hooks/factory.d.ts +3 -3
  37. package/dist/hooks/factory.js +282 -60
  38. package/dist/hooks/injector.js +6 -5
  39. package/dist/interfaces/index.d.ts +5 -2
  40. package/dist/interfaces/index.js +1 -1
  41. package/package.json +1 -1
  42. package/src/decorators/arguments.ts +214 -186
  43. package/src/decorators/controller.ts +22 -14
  44. package/src/decorators/dispatcher.ts +19 -0
  45. package/src/decorators/guard.ts +19 -0
  46. package/src/decorators/http.ts +81 -81
  47. package/src/decorators/index.ts +28 -7
  48. package/src/decorators/inject.ts +13 -13
  49. package/src/decorators/injectable.ts +8 -11
  50. package/src/decorators/middleware.ts +19 -0
  51. package/src/decorators/module.ts +100 -21
  52. package/src/decorators/zodSchema.ts +20 -20
  53. package/src/entities/index.ts +3 -3
  54. package/src/entities/route.ts +328 -328
  55. package/src/entities/router.ts +35 -35
  56. package/src/entities/routerGroup.ts +34 -34
  57. package/src/hooks/factory.ts +653 -319
  58. package/src/hooks/index.ts +2 -2
  59. package/src/hooks/injector.ts +43 -43
  60. package/src/http/clientError.ts +45 -45
  61. package/src/http/index.ts +63 -63
  62. package/src/http/serverError.ts +38 -38
  63. package/src/index.ts +6 -6
  64. package/src/interfaces/controller.d.ts +1 -0
  65. package/src/interfaces/dispatcher.d.ts +3 -0
  66. package/src/interfaces/guard.d.ts +3 -0
  67. package/src/interfaces/index.ts +5 -3
  68. package/src/interfaces/middleware.d.ts +3 -0
  69. package/src/interfaces/module.d.ts +1 -0
  70. package/test.http +31 -30
  71. package/tsconfig.json +107 -107
@@ -1,186 +1,214 @@
1
- import * as Zod from "zod";
2
-
3
- export enum EArgumentTypes {
4
- headers = "HEADERS",
5
- body = "BODY",
6
- params = "PARAMS",
7
- param = "PARAM",
8
- query = "QUERY",
9
- request = "REQUEST"
10
- }
11
-
12
- export type TMetadata =
13
- | {
14
- index: number;
15
- type: EArgumentTypes.headers;
16
- zodSchema?: Zod.Schema;
17
- }
18
- | {
19
- index: number;
20
- type: EArgumentTypes.body;
21
- zodSchema?: Zod.Schema;
22
- parser?: "arrayBuffer" | "blob" | "formData" | "json" | "text";
23
- }
24
- | {
25
- index: number;
26
- type: EArgumentTypes.params;
27
- zodSchema?: Zod.Schema;
28
- }
29
- | {
30
- index: number;
31
- type: EArgumentTypes.param;
32
- key: string;
33
- zodSchema?: Zod.Schema;
34
- }
35
- | {
36
- index: number;
37
- type: EArgumentTypes.query;
38
- zodSchema?: Zod.Schema;
39
- }
40
- | {
41
- index: number;
42
- type: EArgumentTypes.request;
43
- zodSchema?: Zod.Schema;
44
- };
45
-
46
- export const controllerActionArgumentsKey = Symbol.for("__bool:controller.action::arguments__");
47
-
48
- export const Headers = (zodSchema?: Zod.Schema) => {
49
- return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
50
- if (!methodName) {
51
- return;
52
- }
53
-
54
- const headersMetadata = Reflect.getOwnMetadata(controllerActionArgumentsKey, target.constructor, methodName) || {};
55
-
56
- headersMetadata[`argumentIndexes.${parameterIndex}`] = {
57
- index: parameterIndex,
58
- type: EArgumentTypes.headers,
59
- zodSchema: zodSchema
60
- } satisfies Extract<
61
- TMetadata,
62
- {
63
- type: EArgumentTypes.headers;
64
- }
65
- >;
66
-
67
- Reflect.defineMetadata(controllerActionArgumentsKey, headersMetadata, target.constructor, methodName);
68
- };
69
- };
70
-
71
- export const Body = (zodSchema?: Zod.Schema, parser?: "arrayBuffer" | "blob" | "formData" | "json" | "text") => {
72
- return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
73
- if (!methodName) {
74
- return;
75
- }
76
-
77
- const bodyMetadata = Reflect.getOwnMetadata(controllerActionArgumentsKey, target.constructor, methodName) || {};
78
-
79
- bodyMetadata[`argumentIndexes.${parameterIndex}`] = {
80
- index: parameterIndex,
81
- type: EArgumentTypes.body,
82
- zodSchema: zodSchema,
83
- parser: parser
84
- } satisfies Extract<
85
- TMetadata,
86
- {
87
- type: EArgumentTypes.body;
88
- }
89
- >;
90
-
91
- Reflect.defineMetadata(controllerActionArgumentsKey, bodyMetadata, target.constructor, methodName);
92
- };
93
- };
94
-
95
- export const Params = (zodSchema?: Zod.Schema) => {
96
- return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
97
- if (!methodName) {
98
- return;
99
- }
100
-
101
- const paramsMetadata = Reflect.getOwnMetadata(controllerActionArgumentsKey, target.constructor, methodName) || {};
102
-
103
- paramsMetadata[`argumentIndexes.${parameterIndex}`] = {
104
- index: parameterIndex,
105
- type: EArgumentTypes.params,
106
- zodSchema: zodSchema
107
- } satisfies Extract<
108
- TMetadata,
109
- {
110
- type: EArgumentTypes.params;
111
- }
112
- >;
113
-
114
- Reflect.defineMetadata(controllerActionArgumentsKey, paramsMetadata, target.constructor, methodName);
115
- };
116
- };
117
-
118
- export const Param = (key: string, zodSchema?: Zod.Schema) => {
119
- return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
120
- if (!methodName) {
121
- return;
122
- }
123
-
124
- const paramsMetadata = Reflect.getOwnMetadata(controllerActionArgumentsKey, target.constructor, methodName) || {};
125
-
126
- paramsMetadata[`argumentIndexes.${parameterIndex}`] = {
127
- index: parameterIndex,
128
- type: EArgumentTypes.param,
129
- key: key,
130
- zodSchema: zodSchema
131
- } satisfies Extract<
132
- TMetadata,
133
- {
134
- type: EArgumentTypes.param;
135
- }
136
- >;
137
-
138
- Reflect.defineMetadata(controllerActionArgumentsKey, paramsMetadata, target.constructor, methodName);
139
- };
140
- };
141
-
142
- export const Query = (zodSchema?: Zod.Schema) => {
143
- return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
144
- if (!methodName) {
145
- return;
146
- }
147
-
148
- const queryMetadata = Reflect.getOwnMetadata(controllerActionArgumentsKey, target.constructor, methodName) || {};
149
-
150
- queryMetadata[`argumentIndexes.${parameterIndex}`] = {
151
- index: parameterIndex,
152
- type: EArgumentTypes.params,
153
- zodSchema: zodSchema
154
- } satisfies Extract<
155
- TMetadata,
156
- {
157
- type: EArgumentTypes.params;
158
- }
159
- >;
160
-
161
- Reflect.defineMetadata(controllerActionArgumentsKey, queryMetadata, target.constructor, methodName);
162
- };
163
- };
164
-
165
- export const Request = (zodSchema?: Zod.Schema) => {
166
- return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
167
- if (!methodName) {
168
- return;
169
- }
170
-
171
- const queryMetadata = Reflect.getOwnMetadata(controllerActionArgumentsKey, target.constructor, methodName) || {};
172
-
173
- queryMetadata[`argumentIndexes.${parameterIndex}`] = {
174
- index: parameterIndex,
175
- type: EArgumentTypes.request,
176
- zodSchema: zodSchema
177
- } satisfies Extract<
178
- TMetadata,
179
- {
180
- type: EArgumentTypes.request;
181
- }
182
- >;
183
-
184
- Reflect.defineMetadata(controllerActionArgumentsKey, queryMetadata, target.constructor, methodName);
185
- };
186
- };
1
+ import * as Zod from "zod";
2
+
3
+ export enum EArgumentTypes {
4
+ requestHeaders = "REQUEST_HEADERS",
5
+ body = "BODY",
6
+ params = "PARAMS",
7
+ param = "PARAM",
8
+ query = "QUERY",
9
+ request = "REQUEST",
10
+ responseHeaders = "RESPONSE_HEADERS"
11
+ }
12
+
13
+ export type TArgumentsMetadata =
14
+ | {
15
+ index: number;
16
+ type: EArgumentTypes.requestHeaders;
17
+ zodSchema?: Zod.Schema;
18
+ }
19
+ | {
20
+ index: number;
21
+ type: EArgumentTypes.body;
22
+ zodSchema?: Zod.Schema;
23
+ parser?: "arrayBuffer" | "blob" | "formData" | "json" | "text";
24
+ }
25
+ | {
26
+ index: number;
27
+ type: EArgumentTypes.params;
28
+ zodSchema?: Zod.Schema;
29
+ }
30
+ | {
31
+ index: number;
32
+ type: EArgumentTypes.param;
33
+ key: string;
34
+ zodSchema?: Zod.Schema;
35
+ }
36
+ | {
37
+ index: number;
38
+ type: EArgumentTypes.query;
39
+ zodSchema?: Zod.Schema;
40
+ }
41
+ | {
42
+ index: number;
43
+ type: EArgumentTypes.request;
44
+ zodSchema?: Zod.Schema;
45
+ }
46
+ | {
47
+ index: number;
48
+ type: EArgumentTypes.responseHeaders;
49
+ zodSchema?: Zod.Schema;
50
+ };
51
+
52
+ export const argumentsKey = Symbol.for("__bool:arguments__");
53
+
54
+ export const RequestHeaders = (zodSchema?: Zod.Schema) => {
55
+ return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
56
+ if (!methodName) {
57
+ return;
58
+ }
59
+
60
+ const headersMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
61
+
62
+ headersMetadata[`argumentIndexes.${parameterIndex}`] = {
63
+ index: parameterIndex,
64
+ type: EArgumentTypes.requestHeaders,
65
+ zodSchema: zodSchema
66
+ } satisfies Extract<
67
+ TArgumentsMetadata,
68
+ {
69
+ type: EArgumentTypes.requestHeaders;
70
+ }
71
+ >;
72
+
73
+ Reflect.defineMetadata(argumentsKey, headersMetadata, target.constructor, methodName);
74
+ };
75
+ };
76
+
77
+ export const Body = (zodSchema?: Zod.Schema, parser?: "arrayBuffer" | "blob" | "formData" | "json" | "text") => {
78
+ return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
79
+ if (!methodName) {
80
+ return;
81
+ }
82
+
83
+ const bodyMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
84
+
85
+ bodyMetadata[`argumentIndexes.${parameterIndex}`] = {
86
+ index: parameterIndex,
87
+ type: EArgumentTypes.body,
88
+ zodSchema: zodSchema,
89
+ parser: parser
90
+ } satisfies Extract<
91
+ TArgumentsMetadata,
92
+ {
93
+ type: EArgumentTypes.body;
94
+ }
95
+ >;
96
+
97
+ Reflect.defineMetadata(argumentsKey, bodyMetadata, target.constructor, methodName);
98
+ };
99
+ };
100
+
101
+ export const Params =
102
+ (zodSchema?: Zod.Schema) => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
103
+ if (!methodName) {
104
+ return;
105
+ }
106
+
107
+ const paramsMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
108
+
109
+ paramsMetadata[`argumentIndexes.${parameterIndex}`] = {
110
+ index: parameterIndex,
111
+ type: EArgumentTypes.params,
112
+ zodSchema: zodSchema
113
+ } satisfies Extract<
114
+ TArgumentsMetadata,
115
+ {
116
+ type: EArgumentTypes.params;
117
+ }
118
+ >;
119
+
120
+ Reflect.defineMetadata(argumentsKey, paramsMetadata, target.constructor, methodName);
121
+ };
122
+
123
+ export const Param = (key: string, zodSchema?: Zod.Schema) => {
124
+ return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
125
+ if (!methodName) {
126
+ return;
127
+ }
128
+
129
+ const paramsMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
130
+
131
+ paramsMetadata[`argumentIndexes.${parameterIndex}`] = {
132
+ index: parameterIndex,
133
+ type: EArgumentTypes.param,
134
+ key: key,
135
+ zodSchema: zodSchema
136
+ } satisfies Extract<
137
+ TArgumentsMetadata,
138
+ {
139
+ type: EArgumentTypes.param;
140
+ }
141
+ >;
142
+
143
+ Reflect.defineMetadata(argumentsKey, paramsMetadata, target.constructor, methodName);
144
+ };
145
+ };
146
+
147
+ export const Query = (zodSchema?: Zod.Schema) => {
148
+ return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
149
+ if (!methodName) {
150
+ return;
151
+ }
152
+
153
+ const queryMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
154
+
155
+ queryMetadata[`argumentIndexes.${parameterIndex}`] = {
156
+ index: parameterIndex,
157
+ type: EArgumentTypes.params,
158
+ zodSchema: zodSchema
159
+ } satisfies Extract<
160
+ TArgumentsMetadata,
161
+ {
162
+ type: EArgumentTypes.params;
163
+ }
164
+ >;
165
+
166
+ Reflect.defineMetadata(argumentsKey, queryMetadata, target.constructor, methodName);
167
+ };
168
+ };
169
+
170
+ export const Request = (zodSchema?: Zod.Schema) => {
171
+ return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
172
+ if (!methodName) {
173
+ return;
174
+ }
175
+
176
+ const queryMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
177
+
178
+ queryMetadata[`argumentIndexes.${parameterIndex}`] = {
179
+ index: parameterIndex,
180
+ type: EArgumentTypes.request,
181
+ zodSchema: zodSchema
182
+ } satisfies Extract<
183
+ TArgumentsMetadata,
184
+ {
185
+ type: EArgumentTypes.request;
186
+ }
187
+ >;
188
+
189
+ Reflect.defineMetadata(argumentsKey, queryMetadata, target.constructor, methodName);
190
+ };
191
+ };
192
+
193
+ export const ResponseHeaders = (zodSchema?: Zod.Schema) => {
194
+ return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
195
+ if (!methodName) {
196
+ return;
197
+ }
198
+
199
+ const queryMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
200
+
201
+ queryMetadata[`argumentIndexes.${parameterIndex}`] = {
202
+ index: parameterIndex,
203
+ type: EArgumentTypes.responseHeaders,
204
+ zodSchema: zodSchema
205
+ } satisfies Extract<
206
+ TArgumentsMetadata,
207
+ {
208
+ type: EArgumentTypes.responseHeaders;
209
+ }
210
+ >;
211
+
212
+ Reflect.defineMetadata(argumentsKey, queryMetadata, target.constructor, methodName);
213
+ };
214
+ };
@@ -1,14 +1,22 @@
1
- import { injectableKey } from "./injectable";
2
-
3
- export const controllerKey = Symbol.for("__bool:controller__");
4
-
5
- export const Controller =
6
- (prefix: string) =>
7
- <T extends Object>(target: T) => {
8
- Reflect.defineMetadata(controllerKey, !prefix.startsWith("/") ? `/${prefix}` : prefix, target);
9
- Reflect.defineMetadata(injectableKey, undefined, target);
10
-
11
- return target;
12
- };
13
-
14
- export default Controller;
1
+ import type { IController } from "../interfaces/controller";
2
+ import { controllerHttpKey, type THttpMetadata } from "./http";
3
+
4
+ export type TControllerMetadata = Required<{
5
+ prefix: string;
6
+ httpMetadata: THttpMetadata;
7
+ }>;
8
+
9
+ export const controllerKey = Symbol.for("__bool:controller__");
10
+
11
+ export const Controller =
12
+ (prefix: string) =>
13
+ <T extends { new (...args: any[]): IController }>(target: T) => {
14
+ const metadata: TControllerMetadata = {
15
+ prefix: !prefix.startsWith("/") ? `/${prefix}` : prefix,
16
+ httpMetadata: [...(Reflect.getOwnMetadata(controllerHttpKey, target.constructor) || [])]
17
+ };
18
+
19
+ Reflect.defineMetadata(controllerKey, metadata, target);
20
+ };
21
+
22
+ export default Controller;
@@ -0,0 +1,19 @@
1
+ import type { IDispatcher } from "../interfaces/dispatcher";
2
+
3
+ export type TDispatcherMetadata = undefined;
4
+
5
+ export const dispatcherKey = Symbol.for("__bool:dispatcher__");
6
+
7
+ export const Dispatcher =
8
+ () =>
9
+ <T extends { new (...args: any[]): IDispatcher }>(target: T) => {
10
+ if (!("execute" in target.prototype) || typeof target.prototype.execute !== "function") {
11
+ return;
12
+ }
13
+
14
+ const metadata: TDispatcherMetadata = undefined;
15
+
16
+ Reflect.defineMetadata(dispatcherKey, metadata, target);
17
+ };
18
+
19
+ export default Dispatcher;
@@ -0,0 +1,19 @@
1
+ import type { IGuard } from "../interfaces";
2
+
3
+ export type TGuardMetadata = undefined;
4
+
5
+ export const guardKey = Symbol.for("__bool:guard__");
6
+
7
+ export const Guard =
8
+ () =>
9
+ <T extends { new (...args: any[]): IGuard }>(target: T) => {
10
+ if (!("enforce" in target.prototype) || typeof target.prototype.enforce !== "function") {
11
+ return;
12
+ }
13
+
14
+ const metadata = undefined;
15
+
16
+ Reflect.defineMetadata(guardKey, metadata, target);
17
+ };
18
+
19
+ export default Guard;
@@ -1,81 +1,81 @@
1
- export interface IControllerRoute {
2
- path: string;
3
- httpMethod: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS";
4
- methodName: string;
5
- descriptor: PropertyDescriptor;
6
- }
7
-
8
- export const controllerRoutesKey = Symbol.for("__bool:controller.routes__");
9
-
10
- const defaultDecorator =
11
- (path: string, method: "Get" | "Post" | "Put" | "Patch" | "Delete" | "Options") =>
12
- (target: Object, methodName: string, descriptor: PropertyDescriptor) => {
13
- if (!(descriptor.value instanceof Function)) {
14
- throw Error(`${method} decorator only use for class method.`);
15
- }
16
-
17
- // Define controller metadata
18
- Reflect.defineMetadata(
19
- controllerRoutesKey,
20
- [
21
- ...(Reflect.getOwnMetadata(controllerRoutesKey, target.constructor) || []),
22
- {
23
- path: !path.startsWith("/") ? `/${path}` : path,
24
- httpMethod: method.toUpperCase(),
25
- methodName: methodName,
26
- descriptor: descriptor
27
- }
28
- ],
29
- target.constructor
30
- );
31
- };
32
-
33
- /**
34
- *
35
- * @param path
36
- * @returns
37
- */
38
- export const Get = (path = "/") => defaultDecorator(path, "Get");
39
-
40
- /**
41
- *
42
- * @param path
43
- * @returns
44
- */
45
- export const Post = (path = "/") => defaultDecorator(path, "Post");
46
-
47
- /**
48
- *
49
- * @param path
50
- * @returns
51
- */
52
- export const Put = (path = "/") => defaultDecorator(path, "Put");
53
-
54
- /**
55
- *
56
- * @param path
57
- * @returns
58
- */
59
- export const Patch = (path = "/") => defaultDecorator(path, "Patch");
60
-
61
- /**
62
- *
63
- * @param path
64
- * @returns
65
- */
66
- export const Delete = (path = "/") => defaultDecorator(path, "Delete");
67
-
68
- /**
69
- *
70
- * @param path
71
- * @returns
72
- */
73
- export const Options = (path = "/") => defaultDecorator(path, "Options");
74
-
75
- export default {
76
- Get,
77
- Post,
78
- Put,
79
- Patch,
80
- Delete
81
- };
1
+ export type TRoute = {
2
+ path: string;
3
+ httpMethod: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS";
4
+ methodName: string;
5
+ descriptor: PropertyDescriptor;
6
+ };
7
+
8
+ export type THttpMetadata = Array<TRoute>;
9
+
10
+ export const controllerHttpKey = Symbol.for("__bool:controller.http__");
11
+
12
+ const defaultDecorator =
13
+ (path: string, method: "Get" | "Post" | "Put" | "Patch" | "Delete" | "Options") =>
14
+ (target: Object, methodName: string, descriptor: PropertyDescriptor) => {
15
+ if (!(descriptor.value instanceof Function)) {
16
+ throw Error(`${method} decorator only use for class method.`);
17
+ }
18
+
19
+ const metadata: THttpMetadata = [
20
+ ...(Reflect.getOwnMetadata(controllerHttpKey, target.constructor) || []),
21
+ {
22
+ path: !path.startsWith("/") ? `/${path}` : path,
23
+ httpMethod: method.toUpperCase(),
24
+ methodName: methodName,
25
+ descriptor: descriptor
26
+ }
27
+ ];
28
+
29
+ // Define controller metadata
30
+ Reflect.defineMetadata(controllerHttpKey, metadata, target.constructor);
31
+ };
32
+
33
+ /**
34
+ *
35
+ * @param path
36
+ * @returns
37
+ */
38
+ export const Get = (path = "/") => defaultDecorator(path, "Get");
39
+
40
+ /**
41
+ *
42
+ * @param path
43
+ * @returns
44
+ */
45
+ export const Post = (path = "/") => defaultDecorator(path, "Post");
46
+
47
+ /**
48
+ *
49
+ * @param path
50
+ * @returns
51
+ */
52
+ export const Put = (path = "/") => defaultDecorator(path, "Put");
53
+
54
+ /**
55
+ *
56
+ * @param path
57
+ * @returns
58
+ */
59
+ export const Patch = (path = "/") => defaultDecorator(path, "Patch");
60
+
61
+ /**
62
+ *
63
+ * @param path
64
+ * @returns
65
+ */
66
+ export const Delete = (path = "/") => defaultDecorator(path, "Delete");
67
+
68
+ /**
69
+ *
70
+ * @param path
71
+ * @returns
72
+ */
73
+ export const Options = (path = "/") => defaultDecorator(path, "Options");
74
+
75
+ export default {
76
+ Get,
77
+ Post,
78
+ Put,
79
+ Patch,
80
+ Delete
81
+ };