@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
package/__test/controller.ts
CHANGED
|
@@ -33,7 +33,12 @@ const stringSchema = Zod.object({}).refine(async (val) => {
|
|
|
33
33
|
|
|
34
34
|
@Controller("test")
|
|
35
35
|
export class TestController {
|
|
36
|
-
constructor(
|
|
36
|
+
constructor(
|
|
37
|
+
@Inject(Symbol.for("etst")) private readonly testInject: any,
|
|
38
|
+
@Inject(TestService) private readonly testService: IService
|
|
39
|
+
) {
|
|
40
|
+
console.log("testInject", testInject);
|
|
41
|
+
}
|
|
37
42
|
|
|
38
43
|
@Get("abc/:id")
|
|
39
44
|
public get(@Param("id") id: string) {
|
package/__test/module.ts
CHANGED
|
@@ -9,7 +9,17 @@ import { TestRepository } from "./repository";
|
|
|
9
9
|
import { TestService } from "./service";
|
|
10
10
|
import { SecondGuard } from "./secondGuard";
|
|
11
11
|
|
|
12
|
-
@Module
|
|
12
|
+
@Module<{
|
|
13
|
+
mongodb: string;
|
|
14
|
+
}>({
|
|
15
|
+
config: {
|
|
16
|
+
mongodb: "123"
|
|
17
|
+
},
|
|
18
|
+
loaders: {
|
|
19
|
+
mongodb: ({ config }) => {
|
|
20
|
+
return [Symbol.for("etst"), { hehe: "435345" }];
|
|
21
|
+
}
|
|
22
|
+
},
|
|
13
23
|
middlewares: [FirstMiddleware, SecondMiddleware],
|
|
14
24
|
guards: [FirstGuard, SecondGuard],
|
|
15
25
|
beforeDispatchers: [BeforeDispatcher],
|
|
@@ -18,5 +28,3 @@ import { SecondGuard } from "./secondGuard";
|
|
|
18
28
|
dependencies: [TestService, TestRepository]
|
|
19
29
|
})
|
|
20
30
|
export class TestModule {}
|
|
21
|
-
|
|
22
|
-
export default TestModule;
|
|
@@ -1,50 +1,39 @@
|
|
|
1
1
|
import * as Zod from "zod";
|
|
2
|
-
|
|
3
|
-
requestHeaders = "REQUEST_HEADERS",
|
|
4
|
-
body = "BODY",
|
|
5
|
-
params = "PARAMS",
|
|
6
|
-
param = "PARAM",
|
|
7
|
-
query = "QUERY",
|
|
8
|
-
request = "REQUEST",
|
|
9
|
-
responseHeaders = "RESPONSE_HEADERS",
|
|
10
|
-
config = "CONFIG"
|
|
11
|
-
}
|
|
2
|
+
import { bodyArgsKey, contextArgsKey, paramArgsKey, paramsArgsKey, queryArgsKey, requestArgsKey, requestHeadersArgsKey, responseHeadersArgsKey } from "../keys";
|
|
12
3
|
export type TArgumentsMetadata = {
|
|
13
4
|
index: number;
|
|
14
|
-
type:
|
|
5
|
+
type: typeof requestHeadersArgsKey;
|
|
15
6
|
zodSchema?: Zod.Schema;
|
|
16
7
|
} | {
|
|
17
8
|
index: number;
|
|
18
|
-
type:
|
|
9
|
+
type: typeof bodyArgsKey;
|
|
19
10
|
zodSchema?: Zod.Schema;
|
|
20
11
|
parser?: "arrayBuffer" | "blob" | "formData" | "json" | "text";
|
|
21
12
|
} | {
|
|
22
13
|
index: number;
|
|
23
|
-
type:
|
|
14
|
+
type: typeof paramsArgsKey;
|
|
24
15
|
zodSchema?: Zod.Schema;
|
|
25
16
|
} | {
|
|
26
17
|
index: number;
|
|
27
|
-
type:
|
|
18
|
+
type: typeof paramArgsKey;
|
|
28
19
|
key: string;
|
|
29
20
|
zodSchema?: Zod.Schema;
|
|
30
21
|
} | {
|
|
31
22
|
index: number;
|
|
32
|
-
type:
|
|
23
|
+
type: typeof queryArgsKey;
|
|
33
24
|
zodSchema?: Zod.Schema;
|
|
34
25
|
} | {
|
|
35
26
|
index: number;
|
|
36
|
-
type:
|
|
27
|
+
type: typeof requestArgsKey;
|
|
37
28
|
zodSchema?: Zod.Schema;
|
|
38
29
|
} | {
|
|
39
30
|
index: number;
|
|
40
|
-
type:
|
|
31
|
+
type: typeof responseHeadersArgsKey;
|
|
41
32
|
zodSchema?: Zod.Schema;
|
|
42
33
|
} | {
|
|
43
34
|
index: number;
|
|
44
|
-
type:
|
|
45
|
-
zodSchema?: Zod.Schema;
|
|
35
|
+
type: typeof contextArgsKey;
|
|
46
36
|
};
|
|
47
|
-
export declare const argumentsKey: unique symbol;
|
|
48
37
|
export declare const RequestHeaders: (zodSchema?: Zod.Schema) => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
49
38
|
export declare const Body: (zodSchema?: Zod.Schema, parser?: "arrayBuffer" | "blob" | "formData" | "json" | "text") => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
50
39
|
export declare const Params: (zodSchema?: Zod.Schema) => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
@@ -52,4 +41,4 @@ export declare const Param: (key: string, zodSchema?: Zod.Schema) => (target: Ob
|
|
|
52
41
|
export declare const Query: (zodSchema?: Zod.Schema) => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
53
42
|
export declare const Request: (zodSchema?: Zod.Schema) => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
54
43
|
export declare const ResponseHeaders: (zodSchema?: Zod.Schema) => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
55
|
-
export declare const
|
|
44
|
+
export declare const Context: () => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
@@ -1,44 +1,29 @@
|
|
|
1
1
|
import * as Zod from "zod";
|
|
2
|
-
|
|
3
|
-
(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})(EArgumentTypes || (EArgumentTypes = {}));
|
|
13
|
-
export const argumentsKey = Symbol.for("__bool:arguments__");
|
|
14
|
-
export const RequestHeaders = (zodSchema) => {
|
|
15
|
-
return (target, methodName, parameterIndex) => {
|
|
16
|
-
if (!methodName) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
const headersMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
|
|
20
|
-
headersMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
21
|
-
index: parameterIndex,
|
|
22
|
-
type: EArgumentTypes.requestHeaders,
|
|
23
|
-
zodSchema: zodSchema
|
|
24
|
-
};
|
|
25
|
-
Reflect.defineMetadata(argumentsKey, headersMetadata, target.constructor, methodName);
|
|
2
|
+
import { argumentsKey, bodyArgsKey, contextArgsKey, paramArgsKey, paramsArgsKey, queryArgsKey, requestArgsKey, requestHeadersArgsKey, responseHeadersArgsKey } from "../keys";
|
|
3
|
+
export const RequestHeaders = (zodSchema) => (target, methodName, parameterIndex) => {
|
|
4
|
+
if (!methodName) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const requestHeadersMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
|
|
8
|
+
requestHeadersMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
9
|
+
index: parameterIndex,
|
|
10
|
+
type: requestHeadersArgsKey,
|
|
11
|
+
zodSchema: zodSchema
|
|
26
12
|
};
|
|
13
|
+
Reflect.defineMetadata(argumentsKey, requestHeadersMetadata, target.constructor, methodName);
|
|
27
14
|
};
|
|
28
|
-
export const Body = (zodSchema, parser) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
parser: parser
|
|
39
|
-
};
|
|
40
|
-
Reflect.defineMetadata(argumentsKey, bodyMetadata, target.constructor, methodName);
|
|
15
|
+
export const Body = (zodSchema, parser) => (target, methodName, parameterIndex) => {
|
|
16
|
+
if (!methodName) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const bodyMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
|
|
20
|
+
bodyMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
21
|
+
index: parameterIndex,
|
|
22
|
+
type: bodyArgsKey,
|
|
23
|
+
zodSchema: zodSchema,
|
|
24
|
+
parser: parser
|
|
41
25
|
};
|
|
26
|
+
Reflect.defineMetadata(argumentsKey, bodyMetadata, target.constructor, methodName);
|
|
42
27
|
};
|
|
43
28
|
export const Params = (zodSchema) => (target, methodName, parameterIndex) => {
|
|
44
29
|
if (!methodName) {
|
|
@@ -47,79 +32,68 @@ export const Params = (zodSchema) => (target, methodName, parameterIndex) => {
|
|
|
47
32
|
const paramsMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
|
|
48
33
|
paramsMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
49
34
|
index: parameterIndex,
|
|
50
|
-
type:
|
|
35
|
+
type: paramsArgsKey,
|
|
51
36
|
zodSchema: zodSchema
|
|
52
37
|
};
|
|
53
38
|
Reflect.defineMetadata(argumentsKey, paramsMetadata, target.constructor, methodName);
|
|
54
39
|
};
|
|
55
|
-
export const Param = (key, zodSchema) => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
zodSchema: zodSchema
|
|
66
|
-
};
|
|
67
|
-
Reflect.defineMetadata(argumentsKey, paramsMetadata, target.constructor, methodName);
|
|
40
|
+
export const Param = (key, zodSchema) => (target, methodName, parameterIndex) => {
|
|
41
|
+
if (!methodName) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const paramMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
|
|
45
|
+
paramMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
46
|
+
index: parameterIndex,
|
|
47
|
+
type: paramArgsKey,
|
|
48
|
+
key: key,
|
|
49
|
+
zodSchema: zodSchema
|
|
68
50
|
};
|
|
51
|
+
Reflect.defineMetadata(argumentsKey, paramMetadata, target.constructor, methodName);
|
|
69
52
|
};
|
|
70
|
-
export const Query = (zodSchema) => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
zodSchema: zodSchema
|
|
80
|
-
};
|
|
81
|
-
Reflect.defineMetadata(argumentsKey, queryMetadata, target.constructor, methodName);
|
|
53
|
+
export const Query = (zodSchema) => (target, methodName, parameterIndex) => {
|
|
54
|
+
if (!methodName) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const queryMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
|
|
58
|
+
queryMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
59
|
+
index: parameterIndex,
|
|
60
|
+
type: queryArgsKey,
|
|
61
|
+
zodSchema: zodSchema
|
|
82
62
|
};
|
|
63
|
+
Reflect.defineMetadata(argumentsKey, queryMetadata, target.constructor, methodName);
|
|
83
64
|
};
|
|
84
|
-
export const Request = (zodSchema) => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
zodSchema: zodSchema
|
|
94
|
-
};
|
|
95
|
-
Reflect.defineMetadata(argumentsKey, queryMetadata, target.constructor, methodName);
|
|
65
|
+
export const Request = (zodSchema) => (target, methodName, parameterIndex) => {
|
|
66
|
+
if (!methodName) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const requestMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
|
|
70
|
+
requestMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
71
|
+
index: parameterIndex,
|
|
72
|
+
type: requestArgsKey,
|
|
73
|
+
zodSchema: zodSchema
|
|
96
74
|
};
|
|
75
|
+
Reflect.defineMetadata(argumentsKey, requestMetadata, target.constructor, methodName);
|
|
97
76
|
};
|
|
98
|
-
export const ResponseHeaders = (zodSchema) => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
zodSchema: zodSchema
|
|
108
|
-
};
|
|
109
|
-
Reflect.defineMetadata(argumentsKey, queryMetadata, target.constructor, methodName);
|
|
77
|
+
export const ResponseHeaders = (zodSchema) => (target, methodName, parameterIndex) => {
|
|
78
|
+
if (!methodName) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const responseHeadersMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
|
|
82
|
+
responseHeadersMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
83
|
+
index: parameterIndex,
|
|
84
|
+
type: responseHeadersArgsKey,
|
|
85
|
+
zodSchema: zodSchema
|
|
110
86
|
};
|
|
87
|
+
Reflect.defineMetadata(argumentsKey, responseHeadersMetadata, target.constructor, methodName);
|
|
111
88
|
};
|
|
112
|
-
export const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
type: EArgumentTypes.config,
|
|
121
|
-
zodSchema: zodSchema
|
|
122
|
-
};
|
|
123
|
-
Reflect.defineMetadata(argumentsKey, queryMetadata, target.constructor, methodName);
|
|
89
|
+
export const Context = () => (target, methodName, parameterIndex) => {
|
|
90
|
+
if (!methodName) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const responseHeadersMetadata = Reflect.getOwnMetadata(argumentsKey, target.constructor, methodName) || {};
|
|
94
|
+
responseHeadersMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
95
|
+
index: parameterIndex,
|
|
96
|
+
type: contextArgsKey
|
|
124
97
|
};
|
|
98
|
+
Reflect.defineMetadata(argumentsKey, responseHeadersMetadata, target.constructor, methodName);
|
|
125
99
|
};
|
|
@@ -4,7 +4,6 @@ export type TControllerMetadata = Required<{
|
|
|
4
4
|
prefix: string;
|
|
5
5
|
httpMetadata: THttpMetadata;
|
|
6
6
|
}>;
|
|
7
|
-
export declare const controllerKey: unique symbol;
|
|
8
7
|
export declare const Controller: (prefix: string) => <T extends {
|
|
9
8
|
new (...args: any[]): IController;
|
|
10
9
|
}>(target: T) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { controllerHttpKey } from "
|
|
2
|
-
|
|
1
|
+
import { controllerHttpKey, controllerKey } from "../keys";
|
|
2
|
+
import {} from "./http";
|
|
3
3
|
export const Controller = (prefix) => (target) => {
|
|
4
4
|
const metadata = {
|
|
5
5
|
prefix: !prefix.startsWith("/") ? `/${prefix}` : prefix,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { IDispatcher } from "../interfaces/dispatcher";
|
|
2
2
|
export type TDispatcherMetadata = undefined;
|
|
3
|
-
export declare const dispatcherKey: unique symbol;
|
|
4
3
|
export declare const Dispatcher: () => <T extends {
|
|
5
4
|
new (...args: any[]): IDispatcher;
|
|
6
5
|
}>(target: T) => void;
|
package/dist/decorators/guard.js
CHANGED
package/dist/decorators/http.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { controllerHttpKey } from "../keys";
|
|
2
2
|
const defaultDecorator = (path, method) => (target, methodName, descriptor) => {
|
|
3
3
|
if (!(descriptor.value instanceof Function)) {
|
|
4
4
|
throw Error(`${method} decorator only use for class method.`);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export { Body,
|
|
2
|
-
export { Controller
|
|
3
|
-
export { Guard
|
|
4
|
-
export { Inject
|
|
5
|
-
export { Injectable
|
|
6
|
-
export { Middleware
|
|
7
|
-
export { Module
|
|
8
|
-
export { Get, Post, Put, Patch, Delete, Options
|
|
9
|
-
export { ZodSchema
|
|
10
|
-
export { 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";
|
|
11
11
|
export type { TControllerMetadata } from "./controller";
|
|
12
12
|
export type { TModuleMetadata, TModuleOptions } from "./module";
|
|
13
13
|
export type { THttpMetadata } from "./http";
|
package/dist/decorators/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { Body,
|
|
2
|
-
export { Controller
|
|
3
|
-
export { Guard
|
|
4
|
-
export { Inject
|
|
5
|
-
export { Injectable
|
|
6
|
-
export { Middleware
|
|
7
|
-
export { Module
|
|
8
|
-
export { Get, Post, Put, Patch, Delete, Options
|
|
9
|
-
export { ZodSchema
|
|
10
|
-
export { 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";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const Inject: <T extends Object>(classDefinition: {
|
|
1
|
+
export declare const Inject: <T extends Object>(definition: {
|
|
3
2
|
new (...args: any[]): T;
|
|
4
|
-
}) => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
3
|
+
} | string | symbol) => (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
5
4
|
export default Inject;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export const Inject = (
|
|
1
|
+
import { injectKey } from "../keys";
|
|
2
|
+
export const Inject = (definition) => {
|
|
3
3
|
return (target, methodName, parameterIndex) => {
|
|
4
4
|
const designParameterTypes = Reflect.getMetadata(injectKey, target) || [];
|
|
5
|
-
designParameterTypes[parameterIndex] =
|
|
5
|
+
designParameterTypes[parameterIndex] = definition;
|
|
6
6
|
Reflect.defineMetadata(injectKey, designParameterTypes, target);
|
|
7
7
|
};
|
|
8
8
|
};
|
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import type { IModule } from "../interfaces/module";
|
|
2
2
|
type TInstances = Array<new (...args: any[]) => any>;
|
|
3
|
-
|
|
4
|
-
config:
|
|
3
|
+
type TLoaders<TConfig extends {} = {}> = Record<string | symbol, (args: {
|
|
4
|
+
config: TConfig;
|
|
5
|
+
}) => [string | symbol, any] | Promise<[string | symbol, any]>>;
|
|
6
|
+
export type TModuleOptions<TConfig extends {} = {}> = Partial<{
|
|
7
|
+
config: TConfig | (() => TConfig | Promise<TConfig>);
|
|
5
8
|
prefix: string;
|
|
6
9
|
dependencies: TInstances;
|
|
7
|
-
|
|
10
|
+
loaders: TLoaders<TConfig>;
|
|
8
11
|
middlewares: TInstances;
|
|
9
12
|
guards: TInstances;
|
|
10
13
|
beforeDispatchers: TInstances;
|
|
14
|
+
controllers: TInstances;
|
|
11
15
|
afterDispatchers: TInstances;
|
|
12
16
|
}> | undefined;
|
|
13
|
-
export type TModuleMetadata = Partial<{
|
|
14
|
-
config:
|
|
17
|
+
export type TModuleMetadata<TConfig extends {} = {}> = Partial<{
|
|
18
|
+
config: TConfig | ((...args: any[]) => TConfig | Promise<TConfig>);
|
|
15
19
|
prefix: string;
|
|
16
|
-
controllers: TInstances;
|
|
17
20
|
dependencies: TInstances;
|
|
21
|
+
loaders: TLoaders<TConfig>;
|
|
18
22
|
middlewares: TInstances;
|
|
19
23
|
guards: TInstances;
|
|
20
24
|
beforeDispatchers: TInstances;
|
|
25
|
+
controllers: TInstances;
|
|
21
26
|
afterDispatchers: TInstances;
|
|
22
27
|
}> | undefined;
|
|
23
|
-
export declare const
|
|
24
|
-
export declare const Module: (args?: TModuleOptions) => <T extends {
|
|
28
|
+
export declare const Module: <TConfig extends {} = {}>(args?: TModuleOptions<TConfig>) => <T extends {
|
|
25
29
|
new (...args: any[]): IModule;
|
|
26
30
|
}>(target: T) => void;
|
|
27
31
|
export default Module;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import { controllerKey } from "
|
|
2
|
-
import { dispatcherKey } from "./dispatcher";
|
|
3
|
-
import { guardKey } from "./guard";
|
|
4
|
-
import { injectableKey } from "./injectable";
|
|
5
|
-
import { middlewareKey } from "./middleware";
|
|
6
|
-
export const moduleKey = Symbol.for("__bool:module__");
|
|
1
|
+
import { controllerKey, dispatcherKey, guardKey, injectableKey, middlewareKey, moduleKey } from "../keys";
|
|
7
2
|
export const Module = (args) => (target) => {
|
|
8
3
|
const { middlewares, guards, beforeDispatchers, controllers, afterDispatchers, dependencies } = args || {};
|
|
9
4
|
if (middlewares) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Zod from "zod";
|
|
2
|
-
|
|
2
|
+
import { controllerRouteZodSchemaKey } from "../keys";
|
|
3
3
|
export const ZodSchema = (schema) => {
|
|
4
4
|
return (target, methodName, parameterIndex) => {
|
|
5
5
|
if (!methodName) {
|
package/dist/hooks/factory.d.ts
CHANGED
|
@@ -15,6 +15,6 @@ export type TBoolFactoryOptions = Required<{
|
|
|
15
15
|
queryParser: Parameters<typeof Qs.parse>[1];
|
|
16
16
|
}>;
|
|
17
17
|
export declare const controllerCreator: (controllerConstructor: new (...args: any[]) => unknown, group: RouterGroup, prefix?: string) => RouterGroup;
|
|
18
|
-
export declare const argumentsResolution: (data: unknown, zodSchema: Zod.Schema, argumentIndex: number, funcName: string | symbol) => Promise<
|
|
18
|
+
export declare const argumentsResolution: (data: unknown, zodSchema: Zod.Schema, argumentIndex: number, funcName: string | symbol) => Promise<unknown>;
|
|
19
19
|
export declare const BoolFactory: (target: new (...args: any[]) => unknown, options: TBoolFactoryOptions) => Promise<import("bun").Server | undefined>;
|
|
20
20
|
export default BoolFactory;
|