@bool-ts/core 1.6.1 → 1.6.2
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/__test/controller.ts +6 -1
- package/__test/module.ts +11 -3
- package/dist/decorators/arguments.d.ts +10 -21
- package/dist/decorators/arguments.js +73 -99
- package/dist/decorators/controller.d.ts +0 -1
- package/dist/decorators/controller.js +2 -2
- package/dist/decorators/dispatcher.d.ts +0 -1
- package/dist/decorators/dispatcher.js +1 -1
- package/dist/decorators/guard.d.ts +0 -1
- package/dist/decorators/guard.js +1 -1
- package/dist/decorators/http.d.ts +0 -1
- package/dist/decorators/http.js +1 -1
- package/dist/decorators/index.d.ts +10 -10
- package/dist/decorators/index.js +10 -10
- package/dist/decorators/inject.d.ts +2 -3
- package/dist/decorators/inject.js +3 -3
- package/dist/decorators/injectable.d.ts +0 -1
- package/dist/decorators/injectable.js +1 -1
- package/dist/decorators/middleware.d.ts +0 -1
- package/dist/decorators/middleware.js +1 -1
- package/dist/decorators/module.d.ts +12 -8
- package/dist/decorators/module.js +1 -6
- package/dist/decorators/zodSchema.d.ts +0 -1
- package/dist/decorators/zodSchema.js +1 -1
- package/dist/hooks/factory.d.ts +1 -1
- package/dist/hooks/factory.js +126 -129
- package/dist/hooks/injector.d.ts +5 -3
- package/dist/hooks/injector.js +20 -9
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/context.d.ts +4 -0
- package/dist/interfaces/context.js +1 -0
- package/dist/interfaces/index.d.ts +3 -2
- package/dist/keys/index.d.ts +19 -0
- package/dist/keys/index.js +19 -0
- package/package.json +1 -1
- package/src/decorators/arguments.ts +74 -84
- package/src/decorators/controller.ts +2 -3
- package/src/decorators/dispatcher.ts +1 -2
- package/src/decorators/guard.ts +1 -2
- package/src/decorators/http.ts +2 -2
- package/src/decorators/index.ts +10 -21
- package/src/decorators/inject.ts +3 -3
- package/src/decorators/injectable.ts +1 -1
- package/src/decorators/middleware.ts +1 -2
- package/src/decorators/module.ts +14 -14
- package/src/decorators/zodSchema.ts +1 -2
- package/src/hooks/factory.ts +153 -149
- package/src/hooks/injector.ts +26 -11
- package/src/index.ts +1 -0
- package/src/interfaces/context.ts +4 -0
- package/src/interfaces/index.ts +3 -2
- package/src/keys/index.ts +20 -0
|
@@ -1,87 +1,84 @@
|
|
|
1
1
|
import * as Zod from "zod";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
2
|
+
import {
|
|
3
|
+
argumentsKey,
|
|
4
|
+
bodyArgsKey,
|
|
5
|
+
contextArgsKey,
|
|
6
|
+
paramArgsKey,
|
|
7
|
+
paramsArgsKey,
|
|
8
|
+
queryArgsKey,
|
|
9
|
+
requestArgsKey,
|
|
10
|
+
requestHeadersArgsKey,
|
|
11
|
+
responseHeadersArgsKey
|
|
12
|
+
} from "../keys";
|
|
13
13
|
|
|
14
14
|
export type TArgumentsMetadata =
|
|
15
15
|
| {
|
|
16
16
|
index: number;
|
|
17
|
-
type:
|
|
17
|
+
type: typeof requestHeadersArgsKey;
|
|
18
18
|
zodSchema?: Zod.Schema;
|
|
19
19
|
}
|
|
20
20
|
| {
|
|
21
21
|
index: number;
|
|
22
|
-
type:
|
|
22
|
+
type: typeof bodyArgsKey;
|
|
23
23
|
zodSchema?: Zod.Schema;
|
|
24
24
|
parser?: "arrayBuffer" | "blob" | "formData" | "json" | "text";
|
|
25
25
|
}
|
|
26
26
|
| {
|
|
27
27
|
index: number;
|
|
28
|
-
type:
|
|
28
|
+
type: typeof paramsArgsKey;
|
|
29
29
|
zodSchema?: Zod.Schema;
|
|
30
30
|
}
|
|
31
31
|
| {
|
|
32
32
|
index: number;
|
|
33
|
-
type:
|
|
33
|
+
type: typeof paramArgsKey;
|
|
34
34
|
key: string;
|
|
35
35
|
zodSchema?: Zod.Schema;
|
|
36
36
|
}
|
|
37
37
|
| {
|
|
38
38
|
index: number;
|
|
39
|
-
type:
|
|
39
|
+
type: typeof queryArgsKey;
|
|
40
40
|
zodSchema?: Zod.Schema;
|
|
41
41
|
}
|
|
42
42
|
| {
|
|
43
43
|
index: number;
|
|
44
|
-
type:
|
|
44
|
+
type: typeof requestArgsKey;
|
|
45
45
|
zodSchema?: Zod.Schema;
|
|
46
46
|
}
|
|
47
47
|
| {
|
|
48
48
|
index: number;
|
|
49
|
-
type:
|
|
49
|
+
type: typeof responseHeadersArgsKey;
|
|
50
50
|
zodSchema?: Zod.Schema;
|
|
51
51
|
}
|
|
52
52
|
| {
|
|
53
53
|
index: number;
|
|
54
|
-
type:
|
|
55
|
-
zodSchema?: Zod.Schema;
|
|
54
|
+
type: typeof contextArgsKey;
|
|
56
55
|
};
|
|
57
56
|
|
|
58
|
-
export const
|
|
59
|
-
|
|
60
|
-
export const RequestHeaders = (zodSchema?: Zod.Schema) => {
|
|
61
|
-
return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
57
|
+
export const RequestHeaders =
|
|
58
|
+
(zodSchema?: Zod.Schema) => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
62
59
|
if (!methodName) {
|
|
63
60
|
return;
|
|
64
61
|
}
|
|
65
62
|
|
|
66
|
-
const
|
|
63
|
+
const requestHeadersMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
|
|
67
64
|
|
|
68
|
-
|
|
65
|
+
requestHeadersMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
69
66
|
index: parameterIndex,
|
|
70
|
-
type:
|
|
67
|
+
type: requestHeadersArgsKey,
|
|
71
68
|
zodSchema: zodSchema
|
|
72
69
|
} satisfies Extract<
|
|
73
70
|
TArgumentsMetadata,
|
|
74
71
|
{
|
|
75
|
-
type:
|
|
72
|
+
type: typeof requestHeadersArgsKey;
|
|
76
73
|
}
|
|
77
74
|
>;
|
|
78
75
|
|
|
79
|
-
Reflect.defineMetadata(argumentsKey,
|
|
76
|
+
Reflect.defineMetadata(argumentsKey, requestHeadersMetadata, target.constructor, methodName);
|
|
80
77
|
};
|
|
81
|
-
};
|
|
82
78
|
|
|
83
|
-
export const Body =
|
|
84
|
-
|
|
79
|
+
export const Body =
|
|
80
|
+
(zodSchema?: Zod.Schema, parser?: "arrayBuffer" | "blob" | "formData" | "json" | "text") =>
|
|
81
|
+
(target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
85
82
|
if (!methodName) {
|
|
86
83
|
return;
|
|
87
84
|
}
|
|
@@ -90,19 +87,18 @@ export const Body = (zodSchema?: Zod.Schema, parser?: "arrayBuffer" | "blob" | "
|
|
|
90
87
|
|
|
91
88
|
bodyMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
92
89
|
index: parameterIndex,
|
|
93
|
-
type:
|
|
90
|
+
type: bodyArgsKey,
|
|
94
91
|
zodSchema: zodSchema,
|
|
95
92
|
parser: parser
|
|
96
93
|
} satisfies Extract<
|
|
97
94
|
TArgumentsMetadata,
|
|
98
95
|
{
|
|
99
|
-
type:
|
|
96
|
+
type: typeof bodyArgsKey;
|
|
100
97
|
}
|
|
101
98
|
>;
|
|
102
99
|
|
|
103
100
|
Reflect.defineMetadata(argumentsKey, bodyMetadata, target.constructor, methodName);
|
|
104
101
|
};
|
|
105
|
-
};
|
|
106
102
|
|
|
107
103
|
export const Params =
|
|
108
104
|
(zodSchema?: Zod.Schema) => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
@@ -114,44 +110,44 @@ export const Params =
|
|
|
114
110
|
|
|
115
111
|
paramsMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
116
112
|
index: parameterIndex,
|
|
117
|
-
type:
|
|
113
|
+
type: paramsArgsKey,
|
|
118
114
|
zodSchema: zodSchema
|
|
119
115
|
} satisfies Extract<
|
|
120
116
|
TArgumentsMetadata,
|
|
121
117
|
{
|
|
122
|
-
type:
|
|
118
|
+
type: typeof paramsArgsKey;
|
|
123
119
|
}
|
|
124
120
|
>;
|
|
125
121
|
|
|
126
122
|
Reflect.defineMetadata(argumentsKey, paramsMetadata, target.constructor, methodName);
|
|
127
123
|
};
|
|
128
124
|
|
|
129
|
-
export const Param =
|
|
130
|
-
|
|
125
|
+
export const Param =
|
|
126
|
+
(key: string, zodSchema?: Zod.Schema) =>
|
|
127
|
+
(target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
131
128
|
if (!methodName) {
|
|
132
129
|
return;
|
|
133
130
|
}
|
|
134
131
|
|
|
135
|
-
const
|
|
132
|
+
const paramMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
|
|
136
133
|
|
|
137
|
-
|
|
134
|
+
paramMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
138
135
|
index: parameterIndex,
|
|
139
|
-
type:
|
|
136
|
+
type: paramArgsKey,
|
|
140
137
|
key: key,
|
|
141
138
|
zodSchema: zodSchema
|
|
142
139
|
} satisfies Extract<
|
|
143
140
|
TArgumentsMetadata,
|
|
144
141
|
{
|
|
145
|
-
type:
|
|
142
|
+
type: typeof paramArgsKey;
|
|
146
143
|
}
|
|
147
144
|
>;
|
|
148
145
|
|
|
149
|
-
Reflect.defineMetadata(argumentsKey,
|
|
146
|
+
Reflect.defineMetadata(argumentsKey, paramMetadata, target.constructor, methodName);
|
|
150
147
|
};
|
|
151
|
-
};
|
|
152
148
|
|
|
153
|
-
export const Query =
|
|
154
|
-
|
|
149
|
+
export const Query =
|
|
150
|
+
(zodSchema?: Zod.Schema) => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
155
151
|
if (!methodName) {
|
|
156
152
|
return;
|
|
157
153
|
}
|
|
@@ -160,84 +156,78 @@ export const Query = (zodSchema?: Zod.Schema) => {
|
|
|
160
156
|
|
|
161
157
|
queryMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
162
158
|
index: parameterIndex,
|
|
163
|
-
type:
|
|
159
|
+
type: queryArgsKey,
|
|
164
160
|
zodSchema: zodSchema
|
|
165
161
|
} satisfies Extract<
|
|
166
162
|
TArgumentsMetadata,
|
|
167
163
|
{
|
|
168
|
-
type:
|
|
164
|
+
type: typeof queryArgsKey;
|
|
169
165
|
}
|
|
170
166
|
>;
|
|
171
167
|
|
|
172
168
|
Reflect.defineMetadata(argumentsKey, queryMetadata, target.constructor, methodName);
|
|
173
169
|
};
|
|
174
|
-
};
|
|
175
170
|
|
|
176
|
-
export const Request =
|
|
177
|
-
|
|
171
|
+
export const Request =
|
|
172
|
+
(zodSchema?: Zod.Schema) => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
178
173
|
if (!methodName) {
|
|
179
174
|
return;
|
|
180
175
|
}
|
|
181
176
|
|
|
182
|
-
const
|
|
177
|
+
const requestMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
|
|
183
178
|
|
|
184
|
-
|
|
179
|
+
requestMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
185
180
|
index: parameterIndex,
|
|
186
|
-
type:
|
|
181
|
+
type: requestArgsKey,
|
|
187
182
|
zodSchema: zodSchema
|
|
188
183
|
} satisfies Extract<
|
|
189
184
|
TArgumentsMetadata,
|
|
190
185
|
{
|
|
191
|
-
type:
|
|
186
|
+
type: typeof requestArgsKey;
|
|
192
187
|
}
|
|
193
188
|
>;
|
|
194
189
|
|
|
195
|
-
Reflect.defineMetadata(argumentsKey,
|
|
190
|
+
Reflect.defineMetadata(argumentsKey, requestMetadata, target.constructor, methodName);
|
|
196
191
|
};
|
|
197
|
-
};
|
|
198
192
|
|
|
199
|
-
export const ResponseHeaders =
|
|
200
|
-
|
|
193
|
+
export const ResponseHeaders =
|
|
194
|
+
(zodSchema?: Zod.Schema) => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
201
195
|
if (!methodName) {
|
|
202
196
|
return;
|
|
203
197
|
}
|
|
204
198
|
|
|
205
|
-
const
|
|
199
|
+
const responseHeadersMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
|
|
206
200
|
|
|
207
|
-
|
|
201
|
+
responseHeadersMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
208
202
|
index: parameterIndex,
|
|
209
|
-
type:
|
|
203
|
+
type: responseHeadersArgsKey,
|
|
210
204
|
zodSchema: zodSchema
|
|
211
205
|
} satisfies Extract<
|
|
212
206
|
TArgumentsMetadata,
|
|
213
207
|
{
|
|
214
|
-
type:
|
|
208
|
+
type: typeof responseHeadersArgsKey;
|
|
215
209
|
}
|
|
216
210
|
>;
|
|
217
211
|
|
|
218
|
-
Reflect.defineMetadata(argumentsKey,
|
|
212
|
+
Reflect.defineMetadata(argumentsKey, responseHeadersMetadata, target.constructor, methodName);
|
|
219
213
|
};
|
|
220
|
-
};
|
|
221
214
|
|
|
222
|
-
export const
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
215
|
+
export const Context = () => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
216
|
+
if (!methodName) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
227
219
|
|
|
228
|
-
|
|
220
|
+
const responseHeadersMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
|
|
229
221
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
>;
|
|
222
|
+
responseHeadersMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
223
|
+
index: parameterIndex,
|
|
224
|
+
type: contextArgsKey
|
|
225
|
+
} satisfies Extract<
|
|
226
|
+
TArgumentsMetadata,
|
|
227
|
+
{
|
|
228
|
+
type: typeof contextArgsKey;
|
|
229
|
+
}
|
|
230
|
+
>;
|
|
240
231
|
|
|
241
|
-
|
|
242
|
-
};
|
|
232
|
+
Reflect.defineMetadata(argumentsKey, responseHeadersMetadata, target.constructor, methodName);
|
|
243
233
|
};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { IController } from "../interfaces/controller";
|
|
2
|
-
import { controllerHttpKey,
|
|
2
|
+
import { controllerHttpKey, controllerKey } from "../keys";
|
|
3
|
+
import { type THttpMetadata } from "./http";
|
|
3
4
|
|
|
4
5
|
export type TControllerMetadata = Required<{
|
|
5
6
|
prefix: string;
|
|
6
7
|
httpMetadata: THttpMetadata;
|
|
7
8
|
}>;
|
|
8
9
|
|
|
9
|
-
export const controllerKey = Symbol.for("__bool:controller__");
|
|
10
|
-
|
|
11
10
|
export const Controller =
|
|
12
11
|
(prefix: string) =>
|
|
13
12
|
<T extends { new (...args: any[]): IController }>(target: T) => {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { IDispatcher } from "../interfaces/dispatcher";
|
|
2
|
+
import { dispatcherKey } from "../keys";
|
|
2
3
|
|
|
3
4
|
export type TDispatcherMetadata = undefined;
|
|
4
5
|
|
|
5
|
-
export const dispatcherKey = Symbol.for("__bool:dispatcher__");
|
|
6
|
-
|
|
7
6
|
export const Dispatcher =
|
|
8
7
|
() =>
|
|
9
8
|
<T extends { new (...args: any[]): IDispatcher }>(target: T) => {
|
package/src/decorators/guard.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { IGuard } from "../interfaces";
|
|
2
|
+
import { guardKey } from "../keys";
|
|
2
3
|
|
|
3
4
|
export type TGuardMetadata = undefined;
|
|
4
5
|
|
|
5
|
-
export const guardKey = Symbol.for("__bool:guard__");
|
|
6
|
-
|
|
7
6
|
export const Guard =
|
|
8
7
|
() =>
|
|
9
8
|
<T extends { new (...args: any[]): IGuard }>(target: T) => {
|
package/src/decorators/http.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { controllerHttpKey } from "../keys";
|
|
2
|
+
|
|
1
3
|
export type TRoute = {
|
|
2
4
|
path: string;
|
|
3
5
|
httpMethod: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS";
|
|
@@ -7,8 +9,6 @@ export type TRoute = {
|
|
|
7
9
|
|
|
8
10
|
export type THttpMetadata = Array<TRoute>;
|
|
9
11
|
|
|
10
|
-
export const controllerHttpKey = Symbol.for("__bool:controller.http__");
|
|
11
|
-
|
|
12
12
|
const defaultDecorator =
|
|
13
13
|
(path: string, method: "Get" | "Post" | "Put" | "Patch" | "Delete" | "Options") =>
|
|
14
14
|
(target: Object, methodName: string, descriptor: PropertyDescriptor) => {
|
package/src/decorators/index.ts
CHANGED
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
argumentsKey
|
|
12
|
-
} from "./arguments";
|
|
13
|
-
export { Controller, controllerKey } from "./controller";
|
|
14
|
-
export { Guard, guardKey } from "./guard";
|
|
15
|
-
export { Inject, injectKey } from "./inject";
|
|
16
|
-
export { Injectable, injectableKey } from "./injectable";
|
|
17
|
-
export { Middleware, middlewareKey } from "./middleware";
|
|
18
|
-
export { Module, moduleKey } from "./module";
|
|
19
|
-
export { Get, Post, Put, Patch, Delete, Options, controllerHttpKey } from "./http";
|
|
20
|
-
export { ZodSchema, controllerRouteZodSchemaKey } from "./zodSchema";
|
|
21
|
-
export { Dispatcher, dispatcherKey } from "./dispatcher";
|
|
1
|
+
export { Body, Params, Param, Query, Request, RequestHeaders, ResponseHeaders } from "./arguments";
|
|
2
|
+
export { Controller } from "./controller";
|
|
3
|
+
export { Guard } from "./guard";
|
|
4
|
+
export { Inject } from "./inject";
|
|
5
|
+
export { Injectable } from "./injectable";
|
|
6
|
+
export { Middleware } from "./middleware";
|
|
7
|
+
export { Module } from "./module";
|
|
8
|
+
export { Get, Post, Put, Patch, Delete, Options } from "./http";
|
|
9
|
+
export { ZodSchema } from "./zodSchema";
|
|
10
|
+
export { Dispatcher } from "./dispatcher";
|
|
22
11
|
|
|
23
12
|
export type { TControllerMetadata } from "./controller";
|
|
24
13
|
export type { TModuleMetadata, TModuleOptions } from "./module";
|
package/src/decorators/inject.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { injectKey } from "../keys";
|
|
2
2
|
|
|
3
|
-
export const Inject = <T extends Object>(
|
|
3
|
+
export const Inject = <T extends Object>(definition: { new (...args: any[]): T } | string | symbol) => {
|
|
4
4
|
return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
5
5
|
const designParameterTypes: any[] = Reflect.getMetadata(injectKey, target) || [];
|
|
6
6
|
|
|
7
|
-
designParameterTypes[parameterIndex] =
|
|
7
|
+
designParameterTypes[parameterIndex] = definition;
|
|
8
8
|
|
|
9
9
|
Reflect.defineMetadata(injectKey, designParameterTypes, target);
|
|
10
10
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { IMiddleware } from "../interfaces";
|
|
2
|
+
import { middlewareKey } from "../keys";
|
|
2
3
|
|
|
3
4
|
export type TMiddlewareMetadata = undefined;
|
|
4
5
|
|
|
5
|
-
export const middlewareKey = Symbol.for("__bool:middleware__");
|
|
6
|
-
|
|
7
6
|
export const Middleware =
|
|
8
7
|
() =>
|
|
9
8
|
<T extends { new (...args: any[]): IMiddleware }>(target: T) => {
|
package/src/decorators/module.ts
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
import type { IModule } from "../interfaces/module";
|
|
2
|
-
import { controllerKey } from "
|
|
3
|
-
import { dispatcherKey } from "./dispatcher";
|
|
4
|
-
import { guardKey } from "./guard";
|
|
5
|
-
import { injectableKey } from "./injectable";
|
|
6
|
-
import { middlewareKey } from "./middleware";
|
|
2
|
+
import { controllerKey, dispatcherKey, guardKey, injectableKey, middlewareKey, moduleKey } from "../keys";
|
|
7
3
|
|
|
8
4
|
type TInstances = Array<new (...args: any[]) => any>;
|
|
5
|
+
type TLoaders<TConfig extends {} = {}> = Record<
|
|
6
|
+
string | symbol,
|
|
7
|
+
(args: { config: TConfig }) => [string | symbol, any] | Promise<[string | symbol, any]>
|
|
8
|
+
>;
|
|
9
9
|
|
|
10
|
-
export type TModuleOptions =
|
|
10
|
+
export type TModuleOptions<TConfig extends {} = {}> =
|
|
11
11
|
| Partial<{
|
|
12
|
-
config:
|
|
12
|
+
config: TConfig | (() => TConfig | Promise<TConfig>);
|
|
13
13
|
prefix: string;
|
|
14
14
|
dependencies: TInstances;
|
|
15
|
-
|
|
15
|
+
loaders: TLoaders<TConfig>;
|
|
16
16
|
middlewares: TInstances;
|
|
17
17
|
guards: TInstances;
|
|
18
18
|
beforeDispatchers: TInstances;
|
|
19
|
+
controllers: TInstances;
|
|
19
20
|
afterDispatchers: TInstances;
|
|
20
21
|
}>
|
|
21
22
|
| undefined;
|
|
22
23
|
|
|
23
|
-
export type TModuleMetadata =
|
|
24
|
+
export type TModuleMetadata<TConfig extends {} = {}> =
|
|
24
25
|
| Partial<{
|
|
25
|
-
config:
|
|
26
|
+
config: TConfig | ((...args: any[]) => TConfig | Promise<TConfig>);
|
|
26
27
|
prefix: string;
|
|
27
|
-
controllers: TInstances;
|
|
28
28
|
dependencies: TInstances;
|
|
29
|
+
loaders: TLoaders<TConfig>;
|
|
29
30
|
middlewares: TInstances;
|
|
30
31
|
guards: TInstances;
|
|
31
32
|
beforeDispatchers: TInstances;
|
|
33
|
+
controllers: TInstances;
|
|
32
34
|
afterDispatchers: TInstances;
|
|
33
35
|
}>
|
|
34
36
|
| undefined;
|
|
35
37
|
|
|
36
|
-
export const moduleKey = Symbol.for("__bool:module__");
|
|
37
|
-
|
|
38
38
|
export const Module =
|
|
39
|
-
(args?: TModuleOptions) =>
|
|
39
|
+
<TConfig extends {} = {}>(args?: TModuleOptions<TConfig>) =>
|
|
40
40
|
<T extends { new (...args: any[]): IModule }>(target: T) => {
|
|
41
41
|
const { middlewares, guards, beforeDispatchers, controllers, afterDispatchers, dependencies } = args || {};
|
|
42
42
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as Zod from "zod";
|
|
2
|
-
|
|
3
|
-
export const controllerRouteZodSchemaKey = Symbol.for("__bool:controller.route.zodSchema__");
|
|
2
|
+
import { controllerRouteZodSchemaKey } from "../keys";
|
|
4
3
|
|
|
5
4
|
export const ZodSchema = (schema: Zod.Schema) => {
|
|
6
5
|
return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
|