@bool-ts/core 1.9.20 → 1.9.26
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/dist/decorators/arguments.d.ts +11 -11
- package/dist/decorators/container.d.ts +2 -4
- package/dist/decorators/controller.d.ts +2 -4
- package/dist/decorators/guard.d.ts +2 -4
- package/dist/decorators/http.d.ts +11 -11
- package/dist/decorators/inject.d.ts +2 -3
- package/dist/decorators/injectable.d.ts +2 -1
- package/dist/decorators/interceptor.d.ts +2 -4
- package/dist/decorators/middleware.d.ts +2 -4
- package/dist/decorators/module.d.ts +2 -4
- package/dist/decorators/webSocket.d.ts +3 -5
- package/dist/decorators/webSocketArguments.d.ts +5 -5
- package/dist/decorators/webSocketEvent.d.ts +1 -1
- package/dist/decorators/zodSchema.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +16 -16
- package/dist/interfaces/container.d.ts +2 -0
- package/dist/interfaces/controller.d.ts +1 -1
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/interfaces/module.d.ts +1 -1
- package/dist/ultils/constructor.d.ts +1 -0
- package/dist/ultils/index.d.ts +1 -0
- package/package.json +3 -3
- package/src/decorators/arguments.ts +25 -19
- package/src/decorators/container.ts +5 -4
- package/src/decorators/controller.ts +3 -3
- package/src/decorators/guard.ts +5 -3
- package/src/decorators/http.ts +11 -8
- package/src/decorators/inject.ts +7 -3
- package/src/decorators/injectable.ts +4 -2
- package/src/decorators/interceptor.ts +3 -4
- package/src/decorators/middleware.ts +3 -3
- package/src/decorators/module.ts +5 -3
- package/src/decorators/webSocket.ts +3 -3
- package/src/decorators/webSocketArguments.ts +10 -5
- package/src/decorators/webSocketEvent.ts +2 -2
- package/src/decorators/zodSchema.ts +2 -2
- package/src/interfaces/container.ts +1 -0
- package/src/interfaces/controller.ts +1 -1
- package/src/interfaces/index.ts +1 -0
- package/src/interfaces/module.ts +1 -1
- package/src/ultils/constructor.ts +1 -0
- package/src/ultils/index.ts +1 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export interface IController
|
|
1
|
+
export interface IController {
|
|
2
2
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export interface IModule
|
|
1
|
+
export interface IModule {
|
|
2
2
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type TConstructor<T, K extends any[] = any[]> = new (...args: K) => T;
|
package/dist/ultils/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bool-ts/core",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.26",
|
|
4
4
|
"description": "Core package for BoolTS framework",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"@bool-ts/date-time": "^1.0.0",
|
|
34
34
|
"qs": "^6.14.0",
|
|
35
35
|
"reflect-metadata": "^0.2.2",
|
|
36
|
-
"zod": "^3.
|
|
36
|
+
"zod": "^3.25.20"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/bun": "latest",
|
|
40
|
-
"@types/qs": "^6.
|
|
40
|
+
"@types/qs": "^6.14.0",
|
|
41
41
|
"typescript": "^5.8.3"
|
|
42
42
|
},
|
|
43
43
|
"private": false,
|
|
@@ -74,8 +74,8 @@ export type TArgumentsMetadata =
|
|
|
74
74
|
export type TArgumentsMetadataCollection = Record<`argumentIndexes.${number}`, TArgumentsMetadata>;
|
|
75
75
|
|
|
76
76
|
export const RequestHeaders =
|
|
77
|
-
(schema?: Zod.Schema) =>
|
|
78
|
-
(target:
|
|
77
|
+
<T extends Object>(schema?: Zod.Schema) =>
|
|
78
|
+
(target: T, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
79
79
|
if (!methodName) {
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
@@ -98,8 +98,8 @@ export const RequestHeaders =
|
|
|
98
98
|
};
|
|
99
99
|
|
|
100
100
|
export const RequestHeader =
|
|
101
|
-
(key: string, schema?: Zod.Schema) =>
|
|
102
|
-
(target:
|
|
101
|
+
<T extends Object>(key: string, schema?: Zod.Schema) =>
|
|
102
|
+
(target: T, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
103
103
|
if (!methodName) {
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
@@ -123,8 +123,11 @@ export const RequestHeader =
|
|
|
123
123
|
};
|
|
124
124
|
|
|
125
125
|
export const RequestBody =
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
<T extends Object>(
|
|
127
|
+
schema?: Zod.Schema,
|
|
128
|
+
parser?: "arrayBuffer" | "blob" | "formData" | "json" | "text"
|
|
129
|
+
) =>
|
|
130
|
+
(target: T, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
128
131
|
if (!methodName) {
|
|
129
132
|
return;
|
|
130
133
|
}
|
|
@@ -148,8 +151,8 @@ export const RequestBody =
|
|
|
148
151
|
};
|
|
149
152
|
|
|
150
153
|
export const Params =
|
|
151
|
-
(schema?: Zod.Schema) =>
|
|
152
|
-
(target:
|
|
154
|
+
<T extends Object>(schema?: Zod.Schema) =>
|
|
155
|
+
(target: T, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
153
156
|
if (!methodName) {
|
|
154
157
|
return;
|
|
155
158
|
}
|
|
@@ -172,8 +175,8 @@ export const Params =
|
|
|
172
175
|
};
|
|
173
176
|
|
|
174
177
|
export const Param =
|
|
175
|
-
(key: string, schema?: Zod.Schema) =>
|
|
176
|
-
(target:
|
|
178
|
+
<T extends Object>(key: string, schema?: Zod.Schema) =>
|
|
179
|
+
(target: T, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
177
180
|
if (!methodName) {
|
|
178
181
|
return;
|
|
179
182
|
}
|
|
@@ -197,8 +200,8 @@ export const Param =
|
|
|
197
200
|
};
|
|
198
201
|
|
|
199
202
|
export const Query =
|
|
200
|
-
(schema?: Zod.Schema) =>
|
|
201
|
-
(target:
|
|
203
|
+
<T extends Object>(schema?: Zod.Schema) =>
|
|
204
|
+
(target: T, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
202
205
|
if (!methodName) {
|
|
203
206
|
return;
|
|
204
207
|
}
|
|
@@ -221,8 +224,8 @@ export const Query =
|
|
|
221
224
|
};
|
|
222
225
|
|
|
223
226
|
export const Request =
|
|
224
|
-
(schema?: Zod.Schema) =>
|
|
225
|
-
(target:
|
|
227
|
+
<T extends Object>(schema?: Zod.Schema) =>
|
|
228
|
+
(target: T, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
226
229
|
if (!methodName) {
|
|
227
230
|
return;
|
|
228
231
|
}
|
|
@@ -245,7 +248,8 @@ export const Request =
|
|
|
245
248
|
};
|
|
246
249
|
|
|
247
250
|
export const ResponseHeaders =
|
|
248
|
-
|
|
251
|
+
<T extends Object>() =>
|
|
252
|
+
(target: T, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
249
253
|
if (!methodName) {
|
|
250
254
|
return;
|
|
251
255
|
}
|
|
@@ -267,8 +271,8 @@ export const ResponseHeaders =
|
|
|
267
271
|
};
|
|
268
272
|
|
|
269
273
|
export const Context =
|
|
270
|
-
(key?: symbol) =>
|
|
271
|
-
(target:
|
|
274
|
+
<T extends Object>(key?: symbol) =>
|
|
275
|
+
(target: T, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
272
276
|
if (!methodName) {
|
|
273
277
|
return;
|
|
274
278
|
}
|
|
@@ -291,7 +295,8 @@ export const Context =
|
|
|
291
295
|
};
|
|
292
296
|
|
|
293
297
|
export const RouteModel =
|
|
294
|
-
|
|
298
|
+
<T extends Object>() =>
|
|
299
|
+
(target: T, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
295
300
|
if (!methodName) {
|
|
296
301
|
return;
|
|
297
302
|
}
|
|
@@ -313,7 +318,8 @@ export const RouteModel =
|
|
|
313
318
|
};
|
|
314
319
|
|
|
315
320
|
export const HttpServer =
|
|
316
|
-
|
|
321
|
+
<T extends Object>() =>
|
|
322
|
+
(target: T, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
317
323
|
if (!methodName) {
|
|
318
324
|
return;
|
|
319
325
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { IModule } from "../interfaces";
|
|
2
|
-
|
|
3
1
|
import { containerKey, guardKey, injectableKey, middlewareKey, moduleKey } from "../keys";
|
|
2
|
+
import type { TConstructor } from "../ultils";
|
|
4
3
|
|
|
5
4
|
type TInstances = Array<new (...args: any[]) => any>;
|
|
6
5
|
type TLoaders<TConfig extends {} = {}> = Record<
|
|
@@ -38,8 +37,10 @@ export type TContainerMetadata<TConfig extends {} = {}> =
|
|
|
38
37
|
| undefined;
|
|
39
38
|
|
|
40
39
|
export const Container =
|
|
41
|
-
<TConfig extends {} = {}
|
|
42
|
-
|
|
40
|
+
<TConfig extends {} = {}, K extends TConstructor<Object> = TConstructor<Object>>(
|
|
41
|
+
args?: TContainerOptions<TConfig>
|
|
42
|
+
) =>
|
|
43
|
+
(target: K) => {
|
|
43
44
|
const { modules, middlewares, guards, dependencies } = args || {};
|
|
44
45
|
|
|
45
46
|
if (Reflect.hasOwnMetadata(moduleKey, target)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TConstructor } from "../ultils";
|
|
2
2
|
import type { THttpMetadata } from "./http";
|
|
3
3
|
|
|
4
4
|
import { controllerHttpKey, controllerKey } from "../keys";
|
|
@@ -9,8 +9,8 @@ export type TControllerMetadata = Required<{
|
|
|
9
9
|
}>;
|
|
10
10
|
|
|
11
11
|
export const Controller =
|
|
12
|
-
(prefix?: string) =>
|
|
13
|
-
|
|
12
|
+
<T extends TConstructor<Object>>(prefix?: string) =>
|
|
13
|
+
(target: T) => {
|
|
14
14
|
const metadata: TControllerMetadata = {
|
|
15
15
|
prefix: !prefix?.startsWith("/") ? `/${prefix || ""}` : prefix,
|
|
16
16
|
httpMetadata: [...(Reflect.getOwnMetadata(controllerHttpKey, target) || [])]
|
package/src/decorators/guard.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TConstructor } from "../ultils";
|
|
2
2
|
|
|
3
3
|
import { guardKey } from "../keys";
|
|
4
4
|
|
|
5
5
|
export type TGuardMetadata = undefined;
|
|
6
6
|
|
|
7
7
|
export const Guard =
|
|
8
|
-
() =>
|
|
9
|
-
|
|
8
|
+
<T extends TConstructor<Object>>() =>
|
|
9
|
+
(target: T) => {
|
|
10
10
|
if (!("enforce" in target.prototype) || typeof target.prototype.enforce !== "function") {
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
@@ -14,6 +14,8 @@ export const Guard =
|
|
|
14
14
|
const metadata = undefined;
|
|
15
15
|
|
|
16
16
|
Reflect.defineMetadata(guardKey, metadata, target);
|
|
17
|
+
|
|
18
|
+
return target;
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
export default Guard;
|
package/src/decorators/http.ts
CHANGED
|
@@ -13,8 +13,11 @@ export type TRoute = {
|
|
|
13
13
|
export type THttpMetadata = Array<TRoute>;
|
|
14
14
|
|
|
15
15
|
const defaultDecorator =
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
<T, K extends Object>(
|
|
17
|
+
path: string,
|
|
18
|
+
method: "Get" | "Post" | "Put" | "Patch" | "Delete" | "Options"
|
|
19
|
+
) =>
|
|
20
|
+
(target: K, methodName: string | symbol, descriptor: TypedPropertyDescriptor<T>) => {
|
|
18
21
|
if (!(descriptor?.value instanceof Function)) {
|
|
19
22
|
throw Error(`${method} decorator only use for class method.`);
|
|
20
23
|
}
|
|
@@ -42,42 +45,42 @@ const defaultDecorator =
|
|
|
42
45
|
* @param path
|
|
43
46
|
* @returns
|
|
44
47
|
*/
|
|
45
|
-
export const Get = (path = "/") => defaultDecorator(path, "Get");
|
|
48
|
+
export const Get = <T, K extends Object>(path = "/") => defaultDecorator<T, K>(path, "Get");
|
|
46
49
|
|
|
47
50
|
/**
|
|
48
51
|
*
|
|
49
52
|
* @param path
|
|
50
53
|
* @returns
|
|
51
54
|
*/
|
|
52
|
-
export const Post = (path = "/") => defaultDecorator(path, "Post");
|
|
55
|
+
export const Post = <T, K extends Object>(path = "/") => defaultDecorator<T, K>(path, "Post");
|
|
53
56
|
|
|
54
57
|
/**
|
|
55
58
|
*
|
|
56
59
|
* @param path
|
|
57
60
|
* @returns
|
|
58
61
|
*/
|
|
59
|
-
export const Put = (path = "/") => defaultDecorator(path, "Put");
|
|
62
|
+
export const Put = <T, K extends Object>(path = "/") => defaultDecorator<T, K>(path, "Put");
|
|
60
63
|
|
|
61
64
|
/**
|
|
62
65
|
*
|
|
63
66
|
* @param path
|
|
64
67
|
* @returns
|
|
65
68
|
*/
|
|
66
|
-
export const Patch = (path = "/") => defaultDecorator(path, "Patch");
|
|
69
|
+
export const Patch = <T, K extends Object>(path = "/") => defaultDecorator<T, K>(path, "Patch");
|
|
67
70
|
|
|
68
71
|
/**
|
|
69
72
|
*
|
|
70
73
|
* @param path
|
|
71
74
|
* @returns
|
|
72
75
|
*/
|
|
73
|
-
export const Delete = (path = "/") => defaultDecorator(path, "Delete");
|
|
76
|
+
export const Delete = <T, K extends Object>(path = "/") => defaultDecorator<T, K>(path, "Delete");
|
|
74
77
|
|
|
75
78
|
/**
|
|
76
79
|
*
|
|
77
80
|
* @param path
|
|
78
81
|
* @returns
|
|
79
82
|
*/
|
|
80
|
-
export const Options = (path = "/") => defaultDecorator(path, "Options");
|
|
83
|
+
export const Options = <T, K extends Object>(path = "/") => defaultDecorator<T, K>(path, "Options");
|
|
81
84
|
|
|
82
85
|
export default {
|
|
83
86
|
Get,
|
package/src/decorators/inject.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
import type { TConstructor } from "../ultils";
|
|
2
|
+
|
|
1
3
|
import { injectKey } from "../keys";
|
|
2
4
|
|
|
3
|
-
export const Inject =
|
|
4
|
-
|
|
5
|
+
export const Inject =
|
|
6
|
+
<T extends TConstructor<Object>, K extends TConstructor<Object>>(
|
|
7
|
+
definition: T | string | symbol
|
|
8
|
+
) =>
|
|
9
|
+
(target: K, _methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
5
10
|
const designParameterTypes: any[] = Reflect.getMetadata(injectKey, target) || [];
|
|
6
11
|
|
|
7
12
|
designParameterTypes[parameterIndex] = definition;
|
|
8
13
|
|
|
9
14
|
Reflect.defineMetadata(injectKey, designParameterTypes, target);
|
|
10
15
|
};
|
|
11
|
-
};
|
|
12
16
|
|
|
13
17
|
export default Inject;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { TConstructor } from "../ultils";
|
|
2
|
+
|
|
1
3
|
import { injectableKey } from "../keys";
|
|
2
4
|
|
|
3
5
|
export const Injectable =
|
|
4
|
-
() =>
|
|
5
|
-
|
|
6
|
+
<T extends TConstructor<Object>>() =>
|
|
7
|
+
(target: T) =>
|
|
6
8
|
Reflect.defineMetadata(injectableKey, undefined, target);
|
|
7
9
|
|
|
8
10
|
export default Injectable;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import type { IInterceptor } from "../interfaces";
|
|
2
|
-
|
|
3
1
|
import { interceptorKey } from "../keys";
|
|
2
|
+
import type { TConstructor } from "../ultils";
|
|
4
3
|
|
|
5
4
|
export type TInterceptorMetadata = undefined;
|
|
6
5
|
|
|
7
6
|
export const Interceptor =
|
|
8
|
-
() =>
|
|
9
|
-
|
|
7
|
+
<T extends TConstructor<Object>>() =>
|
|
8
|
+
(target: T) => {
|
|
10
9
|
const metadata: TInterceptorMetadata = undefined;
|
|
11
10
|
|
|
12
11
|
Reflect.defineMetadata(interceptorKey, metadata, target);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TConstructor } from "../ultils";
|
|
2
2
|
|
|
3
3
|
import { middlewareKey } from "../keys";
|
|
4
4
|
|
|
5
5
|
export type TMiddlewareMetadata = undefined;
|
|
6
6
|
|
|
7
7
|
export const Middleware =
|
|
8
|
-
() =>
|
|
9
|
-
|
|
8
|
+
<T extends TConstructor<Object>>() =>
|
|
9
|
+
(target: T) => {
|
|
10
10
|
const metadata: TMiddlewareMetadata = undefined;
|
|
11
11
|
|
|
12
12
|
Reflect.defineMetadata(middlewareKey, metadata, target);
|
package/src/decorators/module.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TConstructor } from "../ultils";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
containerKey,
|
|
@@ -53,8 +53,10 @@ export type TModuleMetadata<TConfig extends {} = {}> =
|
|
|
53
53
|
| undefined;
|
|
54
54
|
|
|
55
55
|
export const Module =
|
|
56
|
-
<TConfig extends {} = {}
|
|
57
|
-
|
|
56
|
+
<TConfig extends {} = {}, K extends TConstructor<Object> = TConstructor<Object>>(
|
|
57
|
+
args?: TModuleOptions<TConfig>
|
|
58
|
+
) =>
|
|
59
|
+
(target: K) => {
|
|
58
60
|
if (Reflect.hasOwnMetadata(containerKey, target)) {
|
|
59
61
|
throw new Error(
|
|
60
62
|
`Conflict detected! ${target.name} class cannot be both a Module and a Container.`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Server } from "bun";
|
|
2
|
-
import type {
|
|
2
|
+
import type { TConstructor } from "../ultils";
|
|
3
3
|
import type { TArgumentsMetadataCollection } from "./arguments";
|
|
4
4
|
import type { TWebSocketEventMetadata } from "./webSocketEvent";
|
|
5
5
|
|
|
@@ -42,12 +42,12 @@ const upgradeHandler = (server: Server, request: Request, query: Record<string,
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
export const WebSocket =
|
|
45
|
-
(
|
|
45
|
+
<T extends TConstructor<Object>>(
|
|
46
46
|
args?: Partial<{
|
|
47
47
|
prefix: string;
|
|
48
48
|
}>
|
|
49
49
|
) =>
|
|
50
|
-
|
|
50
|
+
(target: T) => {
|
|
51
51
|
const { prefix } = args || {};
|
|
52
52
|
|
|
53
53
|
target.prototype[upgradeHandlerSymbol] = upgradeHandler;
|
|
@@ -32,7 +32,8 @@ export type TWebsocketArgumentsMetadata =
|
|
|
32
32
|
export type TWebsocketArgumentsMetadataGroup = Record<string, TWebsocketArgumentsMetadata>;
|
|
33
33
|
|
|
34
34
|
export const WebSocketConnection =
|
|
35
|
-
|
|
35
|
+
<T extends Object>() =>
|
|
36
|
+
(target: T, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
36
37
|
if (!methodName) {
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
@@ -60,7 +61,8 @@ export const WebSocketConnection =
|
|
|
60
61
|
};
|
|
61
62
|
|
|
62
63
|
export const WebSocketServer =
|
|
63
|
-
|
|
64
|
+
<T extends Object>() =>
|
|
65
|
+
(target: T, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
64
66
|
if (!methodName) {
|
|
65
67
|
return;
|
|
66
68
|
}
|
|
@@ -88,7 +90,8 @@ export const WebSocketServer =
|
|
|
88
90
|
};
|
|
89
91
|
|
|
90
92
|
export const WebSocketCloseCode =
|
|
91
|
-
|
|
93
|
+
<T extends Object>() =>
|
|
94
|
+
(target: T, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
92
95
|
if (!methodName) {
|
|
93
96
|
return;
|
|
94
97
|
}
|
|
@@ -116,7 +119,8 @@ export const WebSocketCloseCode =
|
|
|
116
119
|
};
|
|
117
120
|
|
|
118
121
|
export const WebSocketCloseReason =
|
|
119
|
-
|
|
122
|
+
<T extends Object>() =>
|
|
123
|
+
(target: T, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
120
124
|
if (!methodName) {
|
|
121
125
|
return;
|
|
122
126
|
}
|
|
@@ -144,7 +148,8 @@ export const WebSocketCloseReason =
|
|
|
144
148
|
};
|
|
145
149
|
|
|
146
150
|
export const WebSocketMessage =
|
|
147
|
-
|
|
151
|
+
<T extends Object>() =>
|
|
152
|
+
(target: T, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
148
153
|
if (!methodName) {
|
|
149
154
|
return;
|
|
150
155
|
}
|
|
@@ -24,8 +24,8 @@ export type TWebSocketEventMetadata = Record<
|
|
|
24
24
|
* @returns
|
|
25
25
|
*/
|
|
26
26
|
export const WebSocketEvent =
|
|
27
|
-
(eventName: "open" | "close" | "message" | "drain" | "ping" | "pong") =>
|
|
28
|
-
(target:
|
|
27
|
+
<T extends Object>(eventName: "open" | "close" | "message" | "drain" | "ping" | "pong") =>
|
|
28
|
+
(target: T, methodName: string, descriptor: PropertyDescriptor) => {
|
|
29
29
|
if (!(descriptor.value instanceof Function)) {
|
|
30
30
|
throw Error("WebSocketEvent decorator only use for class's method.");
|
|
31
31
|
}
|
|
@@ -2,8 +2,8 @@ import * as Zod from "zod";
|
|
|
2
2
|
|
|
3
3
|
import { zodSchemaKey } from "../keys";
|
|
4
4
|
|
|
5
|
-
export const ZodSchema = (schema: Zod.Schema) => {
|
|
6
|
-
return (target:
|
|
5
|
+
export const ZodSchema = <T extends Object>(schema: Zod.Schema) => {
|
|
6
|
+
return (target: T, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
7
7
|
if (!methodName) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export interface IContainer {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export interface IController
|
|
1
|
+
export interface IController {}
|
package/src/interfaces/index.ts
CHANGED
package/src/interfaces/module.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export interface IModule
|
|
1
|
+
export interface IModule {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type TConstructor<T, K extends any[] = any[]> = new (...args: K) => T;
|
package/src/ultils/index.ts
CHANGED